[solved] Upload validation design

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
phpwalker
Forum Commoner
Posts: 81
Joined: Sun Apr 23, 2006 12:18 pm

[solved] Upload validation design

Post by phpwalker »

Hi all,

I'm doing an upload page, and I just want to allow a few types of file can be uploaded to the server. I store the file directly into database.

I've problems of validating the files being uploaded...

My flow is:
1)check if the submit button is set
2)check if it is allow file extension
3)check if the file size exceeds limit
4)check if the file size is equal to zero
5)if everything above is not true, proceed to storing the files..

However, there's problem when I do so. If the file is empty, it will return the message of "invalid file type" instead of "no file is uploaded".

So I've changed the flow a bit, check the file size is equal to zero first. When the file is too large, it will return message "no file is uploaded" instead of "file size exceeds limit"...
The same happens to a file which is disallow file type and is too large, it will also return message "no file is uploaded" instead of "invalid file type"...

Can anyone help me regarding the validation flow?

Thanks a lot...
phpwalker
Forum Commoner
Posts: 81
Joined: Sun Apr 23, 2006 12:18 pm

Re: Upload validation design

Post by phpwalker »

Mod please help me to close this topic, i've solved it...

Thanks...
Post Reply