Page 1 of 1

how can i check with php tht wheather the file field is set

Posted: Thu Dec 01, 2005 1:54 am
by itsmani1
i want to check wheather the file field is set or not? i tried isset($_[file]) but its not worth while.

Posted: Thu Dec 01, 2005 2:02 am
by John Cartwright

Code: Select all

if (!empty($_FILES['fieldname']['tmp_name'])) { 

}
??

Posted: Thu Dec 01, 2005 3:14 am
by phpdevuk
I quite often use the following code as well, just to make sure that there have been no errors

Code: Select all

if (!empty($_FILES['fieldname']['tmp_name'])) { 

    if($_FILES['fieldname']['error']==0){

          // upload file

     }

}