...

View Full Version : Upload mutiple



cipm
07-19-2007, 05:53 AM
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/features.file-upload.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>

mcjwb
07-19-2007, 01:23 PM
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?

cipm
07-19-2007, 02:27 PM
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

mcjwb
07-19-2007, 02:44 PM
If you add
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:

<?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!

cipm
07-19-2007, 05:13 PM
@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.

mcjwb
07-19-2007, 05:24 PM
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:

$dFiles = sizeof($_FILES['dFile']);
to this:

$dFiles = sizeof($_FILES['dFile']['name']);

Have you tried it? Does it do what you want?



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum