Hi guys,

im trying to upload files to my script and have hit an anoying problem.

if the file is bigger than what I allow in in my php.ini config, the $_POST and $_FILE comes through empty - and I cant check that there's been a post to then check the $_FILE error being to big.

How can I check that its been posted and is to big, so I can send a message to the user informing them of this?!

Thanks!

Recommended Answers

All 5 Replies

Why dont you just put an upload limit, that way you dont have to worry about a file being too big.

<?php
if ($_FILES["file"]["size"] > 20000) { // if file is over 20 kb, throw error
  echo "Error: " . $_FILES["file"]["error"] . "<br />";
} else {
  //Code
}
?>

i would do a check like that, but the $_FILES variable is empty, so i cannot check it as youve shown!

show me your code

Hi,

PHP will not be able to check the file size before the file upload is executed. There is no way you can detect on the desktop's directory. File upload has to occur first, and then the script checks on the file size..

There is another way of doing this.. it is called flash dependency class.. try searching filereference class, externalReference class... that should work for what you are trying to achieved.

If you use the flash dependency, you must use this responsibly and only for the purpose of serving the file size detection function and upload function. This can throw many security holes on the desktop side.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.