Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6

Thread: Upload mutiple

  1. #1
    New to the CF scene
    Join Date
    Jul 2007
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Upload mutiple

    Hi,

    I tried to make a page with multiple uplaod, actualy I have 10 file inputs. I follow the instruction from http://www.php.net/manual/en/feature...d.multiple.php but I encountered the following problem:

    - i cannot upload more then 5 files. I mean when I read $_FILES array I have only 5 elements (array size=5).

    I presume that it is some default settings.. but I cannot figure where are made Sad(

    Can somebody tell me where is set variable $_FILES and if I can modify the size of this?
    I'll put simple code sample bellow if you run this code maybe you'll understand better what I mean.
    thanks in advance,
    Cipm

    <?php
    if (@$_REQUEST['u']=='u1') {
    $dFiles = sizeof($_FILES['dFile']);
    echo 'Size of array=' . $dFiles;
    echo '<br/>Dislay size of files<hr/>';

    for ($index = 0; $index < $dFiles; $index++) {
    echo $_FILES['dFile']['size'][$index] . '<br/>';
    }
    }else{
    echo 'Choose files:<br/>';
    }
    ?>
    <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" enctype="multipart/form-data">
    <input type="file" name="dFile[]" size="50" /><br/>
    <input type="file" name="dFile[]" size="50" /><br/>
    <input type="file" name="dFile[]" size="50" /><br/>
    <input type="file" name="dFile[]" size="50" /><br/>
    <input type="file" name="dFile[]" size="50" /><br/>
    <input type="file" name="dFile[]" size="50" /><br/>
    <input type="file" name="dFile[]" size="50" /><br/>
    <input type="file" name="dFile[]" size="50" /><br/>
    <input type="file" name="dFile[]" size="50" /><br/>
    <input type="file" name="dFile[]" size="50" /><br/>

    <input type="hidden" name="u" value="u1"/>


    <input type="submit" name="sumit" value="Send"/>

    </form>

  • #2
    Regular Coder
    Join Date
    Jul 2007
    Location
    UK
    Posts
    223
    Thanks
    0
    Thanked 14 Times in 14 Posts
    There's a limit to the file size you can upload.
    upload_max_filesize in php.ini controls this and defaults to 2M.
    Could this be causing you problems?

  • #3
    New to the CF scene
    Join Date
    Jul 2007
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by mcjwb View Post
    There's a limit to the file size you can upload.
    upload_max_filesize in php.ini controls this and defaults to 2M.
    Could this be causing you problems?
    nope this is set to 150 and all files are around of 10M

  • #4
    Regular Coder
    Join Date
    Jul 2007
    Location
    UK
    Posts
    223
    Thanks
    0
    Thanked 14 Times in 14 Posts
    If you add
    Code:
    print_r($_FILES);
    to your script you will soon see why you always get 5 results!

    The $_FILES array will only ever have 5 entries, they are 'name', 'type', 'tmp_name', 'error' and 'size'. Each one of these is an array.

    So you need to change your script to:
    Code:
    <?php
    if (@$_REQUEST['u']=='u1') {
    $dFiles = sizeof($_FILES['dFile']['name']);
    echo 'Size of array=' . $dFiles;
    echo '<br/>Dislay size of files<hr/>';
    for ($index = 0; $index < $dFiles; $index++) {
    echo $_FILES['dFile']['size'][$index] . '<br/>';
    }
    print'<pre>';
    print_r($_FILES);
    print '</pre>';
    }else{
    echo 'Choose files:<br/>';
    }
    ?>
    <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" enctype="multipart/form-data">
    <input type="file" name="dFile[]" size="50" /><br/>
    <input type="file" name="dFile[]" size="50" /><br/>
    <input type="file" name="dFile[]" size="50" /><br/>
    <input type="file" name="dFile[]" size="50" /><br/>
    <input type="file" name="dFile[]" size="50" /><br/>
    <input type="file" name="dFile[]" size="50" /><br/>
    <input type="file" name="dFile[]" size="50" /><br/>
    <input type="file" name="dFile[]" size="50" /><br/>
    <input type="file" name="dFile[]" size="50" /><br/>
    <input type="file" name="dFile[]" size="50" /><br/>
    <input type="hidden" name="u" value="u1"/>
    
    <input type="submit" name="sumit" value="Send"/>
    </form>
    I'd forgotten how file uploads were handled!

  • #5
    New to the CF scene
    Join Date
    Jul 2007
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    @mcjwb
    Yes, I know that the size of this array is 5, but the question is "how can I change this variable"?
    I am sure that it is possible but I don't know how.

  • #6
    Regular Coder
    Join Date
    Jul 2007
    Location
    UK
    Posts
    223
    Thanks
    0
    Thanked 14 Times in 14 Posts
    You can't change $_FILES, it's a variable created by php in response to uploading files.

    what do you want to change it to, perhaps there is another way?

    Perhaps I wasn't clear in my last post, The uploading of your ten files is working it is the way you are accessing them that isn't.
    In the code I posted above I changed this line:
    Code:
    $dFiles = sizeof($_FILES['dFile']);
    to this:
    Code:
    $dFiles = sizeof($_FILES['dFile']['name']);
    Have you tried it? Does it do what you want?


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •