Jump to content

Uploading Multiple Files with Long File NamesUploading Multiple Files with Long File Names


Recommended Posts

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 post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...