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
    Mar 2005
    Posts
    111
    Thanks
    0
    Thanked 0 Times in 0 Posts

    weird empty $_FILES problem

    I have this form that can upload an image, movie, and an mp3, but none of them are required so i have this for the movie and same thing for mp3 just different var names. The thing that isn't working is if i don't browse to anything in the video or mp3 section it still does the stuff that is in the script below when it shouldn't. Any ideas?
    PHP Code:
    if(!empty($_FILES['movfile'])) {
                include(
    'mov_work.php');
                
    $vars uploadMovie($_FILES['movfile'], "pr");
                
    $ms explode(":"$vars[2]);
                
    $m "INSERT INTO mov VALUES('', '{$ms[0]}', '${ms[1]}', '{$mov_title}', '{$mov_content}', NOW(), '{$month}', '{$day}', '{$year}', '{$vars[0]}', '{$pub}', '{$vars[1]}', '{$vars[3]}', '{$vars[2]}')";
                
    //$m_id = mysql_insert_id();
            


  • #2
    Regular Coder devinemke's Avatar
    Join Date
    Dec 2004
    Location
    NYC
    Posts
    443
    Thanks
    0
    Thanked 12 Times in 11 Posts
    the $_FILES array will always be populated even if no file is uploaded thus empty() will always return FALSE. you need to check the $_FILES['movfile']['error'] value to see if the file was uploaded. read up on the error codes here.


  •  

    Posting Permissions

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