Does a file exist? Or is the user being evil?

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
jolinar
Forum Commoner
Posts: 61
Joined: Tue May 24, 2005 4:24 pm
Location: in front of computer

Does a file exist? Or is the user being evil?

Post by jolinar »

Can anyone suggest a solution to the file upload problem i'm having at the moment. I'm standard HTML forms (with $_FILE) to upload images for a gallery.

Problem - I need to check that the file is actually where before it's added to the database. I'm thinking that I could check the size of the temporary file on the server (after upload) and checking the size. Since a 0 size file is going to be a bogus file.

Any thoughts?
User avatar
ambivalent
Forum Contributor
Posts: 173
Joined: Thu Apr 14, 2005 8:58 pm
Location: Toronto, ON

Post by ambivalent »

Look at is_uploaded_file()

Also, $_FILES['userfile']['size'] can be checked to ensure a value larger than zero.
Post Reply