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 3 of 3
  1. #1
    Regular Coder
    Join Date
    Sep 2008
    Posts
    205
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Question Uploading multiple files - request entity or php issue?

    I'm having trouble uploading multiple files at the same time. For example, if I send two files at the same time, the first file is uploaded but the second is seemingly ignored. I don't know if the problem is with the request entity or the php code. Does anyone know which is the problem? Thanks.

    Below is the "Request Entity" that is submitted to the server:

    Code:
    --3D6atZKLBPujpCZzClN-wz3AJ0Eh-BBWlRr
    Content-Disposition: form-data; name="imgFile[]"; filename="Inbox_Msg_Display.GIF"
    Content-Type: application/octet-stream; charset=ISO-8859-1
    Content-Transfer-Encoding: binary
    --3D6atZKLBPujpCZzClN-wz3AJ0Eh-BBWlRr--
    
    --A2cG-IXHLNC2Rk7kF3fQ5-bQPQpuDwmUU
    Content-Disposition: form-data; name="imgFile[]"; filename="Table_Msg_Content.GIF"
    Content-Type: application/octet-stream; charset=ISO-8859-1
    Content-Transfer-Encoding: binary
    --A2cG-IXHLNC2Rk7kF3fQ5-bQPQpuDwmUU--
    Following is the code I'm using to process the request entity:
    Code:
    for ($i = 0; $i < count($_FILES['imgFile']); $i++){
    	$targetPath = "profile_images/";
    	$targetPath = $targetPath . basename($_FILES['imgFile']['name'][$i]);
    	move_uploaded_file($_FILES['imgFile']['tmp_name'][$i], $targetPath);
    }

  • #2
    UE Antagonizer Fumigator's Avatar
    Join Date
    Dec 2005
    Location
    Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
    Posts
    7,691
    Thanks
    42
    Thanked 637 Times in 625 Posts
    If you echo the $_FILES array at the top of the PHP script using print_r(), you will soon be able to narrow down the problem.

  • #3
    Regular Coder
    Join Date
    Sep 2008
    Posts
    205
    Thanks
    1
    Thanked 0 Times in 0 Posts
    I did as you suggested, I printed the array via
    Code:
    print_r($_Files['imgFile']);
    and the following was printed:

    Array
    (
    [name] => Array
    (
    [0] => Inbox_Msg_Display.GIF
    )

    [type] => Array
    (
    [0] => application/octet-stream
    )

    [tmp_name] => Array
    (
    [0] => C:\WINDOWS\Temp\php1A3.tmp
    )

    [error] => Array
    (
    [0] => 0
    )

    [size] => Array
    (
    [0] => 55250
    )

    )
    This makes me think that the request entity is sending two different requests, rather than one with two files. Could there be any other explanation? Can anyone who is more familiar with request entities let me know if my deduction is correct?


  •  

    Posting Permissions

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