dadamssg87 Posted January 5, 2012 Share Posted January 5, 2012 I'm trying to do a simple image upload. It works fine on my local server but i'm moving all my files to my production server and some files i attempt to upload, via an html form, don't register. The $_FILES variable doesn't exist sometimes. I think its because of the file size but i'm not sure. The form has two inputs: "title" and "userfile". I can put something in the title and attempt to upload a small excel file and both $_POST and $_FILES exist but if i do a larger image file both $_POST and $_FILES don't even get set. I did an "echo ini_get('post_max_size');" and i get "8M". The image i'm attempting to upload is only 0.34M so i should be good there. I've replaced the actual upload script with this, which is how i found out the variables only get set sometimes Any suggestions would be much appreciated. <?php echo "Upload: " . $_FILES["userfile"]["name"] . "<br />"; echo "Type: " . $_FILES["userfile"]["type"] . "<br />"; echo "Size: " . ($_FILES["userfile"]["size"] / 1024) . " Kb<br />"; echo "Stored in: " . $_FILES["userfile"]["tmp_name"]; echo "<hr><pre>"; print_r($_POST); echo "</pre><hr>"; echo "<pre>"; print_r($_FILES); echo "</pre>"; Quote Link to comment https://forums.phpfreaks.com/topic/254379-file-upload-doesnt-exist-sometimes/ Share on other sites More sharing options...
QuickOldCar Posted January 5, 2012 Share Posted January 5, 2012 You can try out this upload script I did and tell me if works or not http://www.phpfreaks.com/forums/index.php?topic=350730.msg1655695#msg1655695 You can also change these in your php.ini file upload_max_filesize = 10M post_max_size = 10M Quote Link to comment https://forums.phpfreaks.com/topic/254379-file-upload-doesnt-exist-sometimes/#findComment-1304358 Share on other sites More sharing options...
dadamssg87 Posted January 5, 2012 Author Share Posted January 5, 2012 that script wouldn't work if there are no $_POST or $_FILES variables Quote Link to comment https://forums.phpfreaks.com/topic/254379-file-upload-doesnt-exist-sometimes/#findComment-1304360 Share on other sites More sharing options...
QuickOldCar Posted January 5, 2012 Share Posted January 5, 2012 The reason for me posting this was to see if your server is capable of uploading the file every time. You never posted anything else with your code. Quote Link to comment https://forums.phpfreaks.com/topic/254379-file-upload-doesnt-exist-sometimes/#findComment-1304361 Share on other sites More sharing options...
PFMaBiSmAd Posted January 5, 2012 Share Posted January 5, 2012 What does the following (added to your test code) show - echo $_SERVER['CONTENT_LENGTH']; Did the display of the echo ini_get() statement display exactly 8M or was it something like 8MB? Quote Link to comment https://forums.phpfreaks.com/topic/254379-file-upload-doesnt-exist-sometimes/#findComment-1304362 Share on other sites More sharing options...
dadamssg87 Posted January 5, 2012 Author Share Posted January 5, 2012 @PFMaBiSmAd, no "B" with it, just "8M". $_SERVER['content_length'] shows 494079. @QuickOldCar, i get "Select your file to upload." with your script. Quote Link to comment https://forums.phpfreaks.com/topic/254379-file-upload-doesnt-exist-sometimes/#findComment-1304363 Share on other sites More sharing options...
QuickOldCar Posted January 5, 2012 Share Posted January 5, 2012 The script works if there is a folder named upload, and the script in the same location as that folder Otherwise edit the target path for where to save your images. Quote Link to comment https://forums.phpfreaks.com/topic/254379-file-upload-doesnt-exist-sometimes/#findComment-1304365 Share on other sites More sharing options...
dadamssg87 Posted January 5, 2012 Author Share Posted January 5, 2012 That response was with my edited target patch. Quote Link to comment https://forums.phpfreaks.com/topic/254379-file-upload-doesnt-exist-sometimes/#findComment-1304366 Share on other sites More sharing options...
PFMaBiSmAd Posted January 5, 2012 Share Posted January 5, 2012 What does adding the following three lines of code, immediately after the <?php tag show - ini_set("display_startup_errors", "1"); ini_set("display_errors", "1"); error_reporting(-1); What does the phpinfo(); output show for both the master and local 'post_max_size'? Any chance your server has the Suhosin hardened php patch installed as it can mess with the external data that can be submitted? Edit: also what php version and what does the phpinfo() output show for register_globals? Quote Link to comment https://forums.phpfreaks.com/topic/254379-file-upload-doesnt-exist-sometimes/#findComment-1304367 Share on other sites More sharing options...
dadamssg87 Posted January 5, 2012 Author Share Posted January 5, 2012 was no change with the displaying of the errors. Still getting php errors that i'm getting an undefined index with $_FILES(the name of the form input). phpinfo() shows 8M for both moster and local. register_globals is off. Quote Link to comment https://forums.phpfreaks.com/topic/254379-file-upload-doesnt-exist-sometimes/#findComment-1304368 Share on other sites More sharing options...
PFMaBiSmAd Posted January 5, 2012 Share Posted January 5, 2012 Is your upload form a simple html form or is it doing something with javascript/ajax/flash that could potentially make the form invalid or prevent the submission of any actual data under certain circumstances? I would contact your web host to see if they have imposed some upload size policy that is outside of what the php settings can affect. Quote Link to comment https://forums.phpfreaks.com/topic/254379-file-upload-doesnt-exist-sometimes/#findComment-1304542 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.