OtagoHarbour Posted January 3, 2014 Share Posted January 3, 2014 I was not sure whether this question belongs here of in the PHP forum since my problem may be with one or the other or both. I use the following html and php code to select and upload multiple files.HTML <form action="uploadFiles.php" method="post" enctype="multipart/form-data"> <label for="file">Filename:</label> <input type="file" name="file[]" multiple="multiple"/></br> <input type="submit" name="submit[]" value="submit" /> </form> uploadFiles.php <?php if(isset($_POST['submit'])) { if ($_FILES["file[]"]["error"] > 0) { echo "Error: " . $_FILES["file[]"]["error"] . "<br>"; } else { $numFilesUploaded=count($_FILES['file']['name']); echo "No. files uploaded : ".$numFilesUploaded."<br><br>"; for ($inc=0; $inc<$numFilesUploaded; ++$inc){ echo "File " . $inc . ": " . $_FILES["file"]["name"][$inc] . "<br>"; echo "Upload: " . $_FILES["file"]["name"][$inc] . "<br>"; echo "Type: " . $_FILES["file"]["type"][$inc] . "<br>"; echo "Size: " . ($_FILES["file"]["size"][$inc] / 1024) . " kB<br>"; echo "Stored in: " . $_FILES["file"]["tmp_name"][$inc]; echo "<br><br>"; } } } ?> If I select 2 files, each having names of character length 8, the code works fine. However, when I select files with names of character length 32, $_POST is an empty array. What is the best way to upload multiple files where the file names may be long? I ran phpinfo() and it did indeed say "This server is protected with the Suhosin Patch 0.9.10 ..." Some people have suggested that it may be a problem with the file size. However, I never get to even try to upload files since the names are not properly passed to the PHP code if the filenames are too long. Also, I have modified /etc/php5/apache2/php.ini to allow the upload of files larger than the files I am trying to upload. Also, I do not have this problem if I shorten the names of the files I am having trouble with. Many thanks in advance for any help. Link to comment Share on other sites More sharing options...
OtagoHarbour Posted January 5, 2014 Author Share Posted January 5, 2014 I have figured out that it is not the length of the file names but the size of the files. The PHP post failed because the files were 11 MB each. Two of them exceeded the php.ini limit of 20 MB. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now