...

View Full Version : Uploading multiple files - request entity or php issue?



Dan06
03-16-2009, 05:08 PM
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:


--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:

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);
}

Fumigator
03-16-2009, 05:49 PM
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.

Dan06
03-16-2009, 06:38 PM
I did as you suggested, I printed the array via

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?



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum