Thursday, 14 January 2016

Detect if file is not empty before upload in PHP

I was working with a script developed by something else and i got hooked because i could not post content due to some logical issue with the programming of the script.
The script was design to upload file whether empty or not and this was causing problem for me because i am not attaching a file to the post.
Here is the code to here detect if the file upload is not empty:
if(!$_FILES["file"]['error'] == 4){ //process upload }

That solves the issue, i could now post without upload a file.


Follow me on twitter: http://www.twitter.com/_josiah_king Join me on Google+: https://www.plus.google.com/u/0/113541005774136102412/posts/p/pub?cfem=1

No comments:

Post a Comment