tpl41803 Posted June 7, 2010 Share Posted June 7, 2010 Hey all I have an issue with a really bare file uploading script which is supposed to upload up to 40 files at the same time, rename them, and save them to a predetermined directory. My code on a page called PHOTOS looks like this (shortened because it's the same thing repeated for each input): <form enctype="multipart/form-data" action="upload.php" method="POST"> <input type="hidden" name="destination" value="$row['folder']" /> 1. <input name="ufile[]" type="file" id="ufile[]" /><br /> 2. <input name="ufile[]" type="file" id="ufile[]" /><br /> 3. <input name="ufile[]" type="file" id="ufile[]" /><br /> 4. <input name="ufile[]" type="file" id="ufile[]" /><br /> etc... and my php action, "upload.php" looks like this: $destination = $_POST['destination']; $path1= "../sales/inventory/$destination/". "1.jpg"; $path2= "../sales/inventory/$destination/". "2.jpg"; $path3= "../sales/inventory/$destination/". "3.jpg"; $path4= "../sales/inventory/$destination/". "4.jpg"; etc.... if (!empty($_FILES['ufile']['tmp_name'][0])) { copy($_FILES['ufile']['tmp_name'][0], $path1); } if (!empty($_FILES['ufile']['tmp_name'][1])) { copy($_FILES['ufile']['tmp_name'][1], $path2); } if (!empty($_FILES['ufile']['tmp_name'][2])) { copy($_FILES['ufile']['tmp_name'][2], $path3); } if (!empty($_FILES['ufile']['tmp_name'][3])) { copy($_FILES['ufile']['tmp_name'][3], $path4); } etc... I'm sure there are prettier ways of doing this, but it works fine until I upload a 21st files. The script for some reason will only save the first 20 files to the destination directory. I have changed the max file upload size to reflect the amount of bytes I am passing through this script (which is rarely more than 4.5mb). Any ideas why this might be happening? Thanks a lot, always appreciate the help I get when i come here! Quote Link to comment https://forums.phpfreaks.com/topic/204142-simple-multiple-file-upload-script-issues/ Share on other sites More sharing options...
dabaR Posted June 8, 2010 Share Posted June 8, 2010 It could I think be several reasons. Can you add error_reporting(E_ALL); to the top of the upload.php script? That might give you the error. Quote Link to comment https://forums.phpfreaks.com/topic/204142-simple-multiple-file-upload-script-issues/#findComment-1069246 Share on other sites More sharing options...
tpl41803 Posted June 8, 2010 Author Share Posted June 8, 2010 added but the result is the same and i don't get any errors reported :-/ Quote Link to comment https://forums.phpfreaks.com/topic/204142-simple-multiple-file-upload-script-issues/#findComment-1069505 Share on other sites More sharing options...
dabaR Posted June 8, 2010 Share Posted June 8, 2010 Is this your own server? Can you check that display_errors is on? http://php.net/manual/en/errorfunc.configuration.php Do you generally get errors when you make a syntax error in your code? Quote Link to comment https://forums.phpfreaks.com/topic/204142-simple-multiple-file-upload-script-issues/#findComment-1069513 Share on other sites More sharing options...
tpl41803 Posted June 8, 2010 Author Share Posted June 8, 2010 yes i do get error messages when i make syntax errors and things so i know error messages are turned on Quote Link to comment https://forums.phpfreaks.com/topic/204142-simple-multiple-file-upload-script-issues/#findComment-1069530 Share on other sites More sharing options...
tpl41803 Posted June 8, 2010 Author Share Posted June 8, 2010 I have been playing with the script a little and adding some checks into the code and this new version produces the exact same problem, example: if (!empty($_FILES['ufile']['tmp_name'][0])) { if (!copy($_FILES['ufile']['tmp_name'][0], $path0)) { echo "failed to save '.$path1.'"; } echo "'.$path0.' was saved <br /><br />"; } else { echo "'.$path0.' was empty <br /><br />"; } Now, when I upload the first 20 files, i receive "XXXX was saved" and 21-40 returns "XXXX was empty" DOES php only allow the userfile array only count to 20? I'm not sure if this is really the issue, because if i only upload the 21st file, for example, the script still returns "XXXX was empty" for number 21. not sure :-/ Quote Link to comment https://forums.phpfreaks.com/topic/204142-simple-multiple-file-upload-script-issues/#findComment-1069536 Share on other sites More sharing options...
dabaR Posted June 8, 2010 Share Posted June 8, 2010 Oh, you can also print_r($_FILES), maybe that will help. Quote Link to comment https://forums.phpfreaks.com/topic/204142-simple-multiple-file-upload-script-issues/#findComment-1069538 Share on other sites More sharing options...
tpl41803 Posted June 8, 2010 Author Share Posted June 8, 2010 well this is interesting, when i print_r($_FILES) i get an array that counts 0-19. It should be counting 0-39. Quote Link to comment https://forums.phpfreaks.com/topic/204142-simple-multiple-file-upload-script-issues/#findComment-1069545 Share on other sites More sharing options...
kenrbnsn Posted June 8, 2010 Share Posted June 8, 2010 When I try this simple script: <?php <?php if (isset($_POST['submit'])) { echo '<pre>' . print_r($_FILES['ufile'],true) . '</pre>'; } ?> <html> <head> <title>Upload many files</title> </head> <body> <form enctype="multipart/form-data" action="" method="POST"> <ol> <?php for($i=0;$i<40;++$i) { echo '<li><input name="ufile[]" type="file" id="ufile[]" /><br />' . "\n"; } ?> </ol> <input type="submit" value="Upload" name="submit"> </form> </body> </html> I get the following warning: Warning: Maximum number of allowable file uploads has been exceeded in Unknown on line 0 And it only populates 20 entries in the $_FILES array. Ken Quote Link to comment https://forums.phpfreaks.com/topic/204142-simple-multiple-file-upload-script-issues/#findComment-1069546 Share on other sites More sharing options...
tpl41803 Posted June 8, 2010 Author Share Posted June 8, 2010 that's more or less what I am encountering but I am not receiving the error i guess that means that you can only upload 20 files at a time? Quote Link to comment https://forums.phpfreaks.com/topic/204142-simple-multiple-file-upload-script-issues/#findComment-1069547 Share on other sites More sharing options...
tpl41803 Posted June 8, 2010 Author Share Posted June 8, 2010 seems this is the issue, i have broken my script into 2 separate pages, each uploads 20 files at a time, this is not EXACTLY what I was looking for, but it will do until I can find away to override what seems to be a 20 file maximum I've looked through the php.ini settings to see if there is a way to change it but it seems like there isn;t thanks for all your help :-D Quote Link to comment https://forums.phpfreaks.com/topic/204142-simple-multiple-file-upload-script-issues/#findComment-1069562 Share on other sites More sharing options...
ignace Posted June 8, 2010 Share Posted June 8, 2010 You can increase the count by altering max_file_uploads cf http://www.php.net/manual/en/ini.core.php#ini.max-file-uploads Chances are you also may want to increase upload_max_filesize with 8M you would have 200KB for each file. Quote Link to comment https://forums.phpfreaks.com/topic/204142-simple-multiple-file-upload-script-issues/#findComment-1069570 Share on other sites More sharing options...
tpl41803 Posted June 8, 2010 Author Share Posted June 8, 2010 ah that's exactly what i needed, thanks so much :-D Quote Link to comment https://forums.phpfreaks.com/topic/204142-simple-multiple-file-upload-script-issues/#findComment-1069608 Share on other sites More sharing options...
PFMaBiSmAd Posted June 8, 2010 Share Posted June 8, 2010 Actually, the upload_max_filesize applies to each file being uploaded. The post_max_size applies to the sum of the data from one form. Quote Link to comment https://forums.phpfreaks.com/topic/204142-simple-multiple-file-upload-script-issues/#findComment-1069612 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.