Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Regular Coder
    Join Date
    May 2005
    Posts
    224
    Thanks
    1
    Thanked 0 Times in 0 Posts

    get "value" of file upload field

    I have a file upload field in my form.

    I have two questions relating to it.

    1) How would I validate it to make sure some type of file was chosen (type doesn't matter, just that the box wasn't empty)
    (I tried:
    PHP Code:
    if((empty($_FILES["thumb"]))){ 
    but that didn't work)
    and

    2) How do I get the value of what was put in the field (the file path), so that it can be re-inserted into the file field via php?

    Edit:
    Got answer to first: I needed
    PHP Code:
    $_FILES['thumb']['name']; 
    Second question: I read that value field doesn't work in file uploads...I can live w/o it, but if there is a way, I'd like to know
    Last edited by Crazydog; 08-01-2007 at 11:03 PM.

  • #2
    Senior Coder kbluhm's Avatar
    Join Date
    Apr 2007
    Location
    Philadelphia, PA, USA
    Posts
    1,509
    Thanks
    3
    Thanked 258 Times in 254 Posts
    PHP Code:
    <?php

    if ( $_FILES['thumb']['error'] === UPLOAD_ERR_NO_FILE )
        exit( 
    'No file was uploaded' );

    ?>
    http://www.php.net/manual/en/feature...oad.errors.php
    Last edited by kbluhm; 08-02-2007 at 05:49 PM.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •