View Full Version : weird empty $_FILES problem

07-26-2007, 05:49 PM
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?

if(!empty($_FILES['movfile'])) {
$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();

07-26-2007, 09:29 PM
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 (http://www.php.net/manual/en/features.file-upload.errors.php).

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum