PHP File Upload works half the time, when fails return code 0?

Good day everyone,

I’ve create an internal site for my job and am using XAMPP to manage the server (since we are small and do not have the finances for much better). I’ve created an upload script to allow others to upload documents pertaining to customers and when we upload the documents, half the time they upload flawlessly while the rest of the time it fails with a return code of 0. I’ve done some research on this just to confirm my suspicions and found that code 0 means that the file was uploaded without error, which doesn’t make sense since it gave me an error and prevented the upload. Attached is the message returned from XAMPP. Whatcha guys think?

Hi photonist, welcome to the forums,

My thinking is that “0” means FALSE, not “without error”

Thank you! Glad to be here!

Hm, ok. Here is the link I used for reference.

I’m just now reading the bolded words above it… Does this still apply? xP
What do you think it could be?

Can you check on the file_size() of all files that failed to upload?

Alright, here is there error with the file size as well as the file type.

Are the files being stored in the file system or in the database? If they are being stored in the database, what storage engine does the table use?

In php.ini what settings do you have for:


They are stored in the file system but database records are being stored to keep track of where they are and for later retrieval from other pages. I am using MySQL for my database.

max_execution_time = 30
max_input_time = 60
memory_limit = 512M
post_max_size = 8M
upload_max_size = 100M

Set PHP’s error reporting level to maximum (so that it reports absolutely every error) and then try uploading one of the files that is known to not upload properly

Well this is awkward… When I re-uploaded the file, the error returned said the upload directory didn’t exist and when I went to make sure, I saw that it did exist but there was a slight difference between the two names… I need to incorporate that in to my error detection script, check if the directory exists FIRST then upload and spit back an error if it doesn’t… :shifty:

Anywho… Thank you everyone for helping me out, it’s much appreciated! and thanks SpacePhoenix for reminding me of that option :slight_smile:

Well this is awkward… there was a misspelling in the upload directory… What a pain huh?

Anywho… Thank you everyone who helped me figure this out! Still need to review my PHP programming… PowerShell is getting the best of me! :smiley:

@photonist ;
You previously mentioned that half the time files uploaded OK, where did they go :slight_smile:

Well, thing is… The uploads all worked for customers that do not have any special characters in their name as my testing customer does, it has an apostrophe in it and when the system went to upload, the upload script doesn’t transcribe the apostrophe to html code:


so it couldn’t upload because of that :blush:

I have been caught out far too many times (especially by a Windows space in the file name) and now endeavour to ensure the file_exists($ff)