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

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
itsmani1
Forum Regular
Posts: 791
Joined: Mon Sep 29, 2003 2:26 am
Location: Islamabad Pakistan
Contact:

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

Post by itsmani1 »

i want to check wheather the file field is set or not? i tried isset($_[file]) but its not worth while.
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

Code: Select all

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

}
??
User avatar
phpdevuk
Forum Contributor
Posts: 220
Joined: Mon Jul 04, 2005 5:31 am
Location: UK
Contact:

Post 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

     }

}
Post Reply