Uploading Files
Posted: Thu Mar 10, 2005 6:10 am
Maybe i am being really thick and missing something simple, but can someone please help.
I'm trying to expand the single file upload form into a multiple user defined upload files form. Where the single form allows you to upload single files, i have managed to modify the form so that the user can select how many files they want to upload in a single submit
The single file upload script i am using is as follows:
which stores an array in the form
which is easy to itterate and perform the necessary functions.
What i have done is modify the upload form to allow any number of uploads in one submit. So the example below allows 6 uploads.
What i can't do is manipulate the array so that i can itterate through it. The array to store 6 uploads looks like this:
what i have tried to do is re-build the array in the form:
but i am having difficulty with array_merge since keys are overwritten.
Can anyone provide any clues or help with either manipulating the original array so that i can extract the values for each file or re-building the array in the new format.
Thanks.
I'm trying to expand the single file upload form into a multiple user defined upload files form. Where the single form allows you to upload single files, i have managed to modify the form so that the user can select how many files they want to upload in a single submit
The single file upload script i am using is as follows:
Code: Select all
<form enctype='multipart/form-data' action='admin.php?page=upload_images' method='post' name='upload_form'>
<tr>
<td style="e;text-align:right;"e;>Select Category</td>
<td>
<select name='category'>
<option value="e;1"e;>Jan</option>
<option value="e;2"e;>Feb</option>
<option value="e;3"e;>Mar</option>
<option value="e;4"e;>Apr</option>
<option value="e;5"e;>May</option>
</select>
</td>
</tr>
<tr><td><p> </p></td></tr>
<tr>
<td style="e;text-align:right;"e;>Photo:</td>
<td><input name='photo_filenameї]' type='file' /></td>
</tr>
<tr style="e;vertical-align:top;"e;>
<td style="e;text-align:right;"e;>Caption:</td>
<td width="e;100%"e;><textarea name='photo_captionї]' cols='30' rows='1'></textarea></td>
</tr>
<tr>
<td><input type='submit' name='submit' value='Add Photos' /></td>
</tr>
</form>Code: Select all
Array
(
їname] => Array
(
ї0] => 001.jpg
)
їtype] => Array
(
ї0] => image/jpeg
)
їtmp_name] => Array
(
ї0] => C:\PHP\uploadtemp\phpD3B.tmp
)
їerror] => Array
(
ї0] => 0
)
їsize] => Array
(
ї0] => 118007
)
)What i have done is modify the upload form to allow any number of uploads in one submit. So the example below allows 6 uploads.
What i can't do is manipulate the array so that i can itterate through it. The array to store 6 uploads looks like this:
Code: Select all
Array
(
їname] => Array
(
ї0] => 001.jpg
ї1] => 002.jpg
ї2] => 004.jpg
ї3] => 005.jpg
ї4] => 006.jpg
ї5] => 009.jpg
)
їtype] => Array
(
ї0] => image/jpeg
ї1] => image/jpeg
ї2] => image/jpeg
ї3] => image/jpeg
ї4] => image/jpeg
ї5] => image/jpeg
)
їtmp_name] => Array
(
ї0] => C:\PHP\uploadtemp\phpD3C.tmp
ї1] => C:\PHP\uploadtemp\phpD3D.tmp
ї2] => C:\PHP\uploadtemp\phpD3E.tmp
ї3] => C:\PHP\uploadtemp\phpD3F.tmp
ї4] => C:\PHP\uploadtemp\phpD40.tmp
ї5] => C:\PHP\uploadtemp\phpD41.tmp
)
їerror] => Array
(
ї0] => 0
ї1] => 0
ї2] => 0
ї3] => 0
ї4] => 0
ї5] => 0
)
їsize] => Array
(
ї0] => 118007
ї1] => 183868
ї2] => 138343
ї3] => 128347
ї4] => 185776
ї5] => 149777
)
)Code: Select all
Array
(
ї0] => Array
(
їname] => 001.jpg
їtype] => image/jpeg
їtmp_name] => C:\PHP\uploadtemp\phpD3C.tmp
їerror] => 0
їsize] => 118007
)
ї1] => Array
(
їname] =>
їtype] =>
їtmp_name] =>
їerror] =>
їsize] =>
)
ї2] => Array
(
їname] =>
їtype] =>
їtmp_name] =>
їerror] =>
їsize] =>
)
ї3] => Array
(
їname] =>
їtype] =>
їtmp_name] =>
їerror] =>
їsize] =>
)
ї4] => Array
(
їname] =>
їtype] =>
їtmp_name] =>
їerror] =>
їsize] =>
)
ї5] => Array
(
їname] =>
їtype] =>
їtmp_name] =>
їerror] =>
їsize] =>
)
)Can anyone provide any clues or help with either manipulating the original array so that i can extract the values for each file or re-building the array in the new format.
Thanks.