if (is_uploaded_file($file_array["tmp_name"])) {
move_uploaded_file($file_array["tmp_name"], "$file_dir/".
$file_array["name"]) or die ("Couldn't copy");
echo "file was moved! ";
}
}
_________________________________________________________
Lets say the HTML from that sends data to this script has 3 upload
forms that get send to $_FILES, would I access the data by modifying
the following line from the above example:
....
foreach($_FILES[' UPLOADIMAGE1 '] as $file_name => $file_array) {
....
....
foreach($_FILES[' UPLOADIMAGE2 '] as $file_name => $file_array) {
....
....
foreach($_FILES[' UPLOADIMAGE3 '] as $file_name => $file_array) {
....
Thanks for reading!
Matt Cheezoid
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
On Wed, Nov 11, 2009 at 12:09 PM, Matthew Croud wrote:
> Dear lords of PHP,
>
> I have a working image upload script that meets all my needs,
> My question is I need to upload multiple images using the same form,
>
> This is the PHP part I have so far, largely taken from a book:
> _________________________________________________________
>
> $file_dir = "/public_html/uploads";
> foreach($_FILES as $file_name => $file_array) {
> echo "path: ".$file_array["tmp_name"]." \n";
> echo "name: ".$file_array["name"]." \n";
>
> $UploadName = $file_array["name"];
>
> if (is_uploaded_file($file_array["tmp_name"])) {
> move_uploaded_file($file_array["tmp_name"],
> "$file_dir/".$file_array["name"]) or die ("Couldn't copy");
> echo "file was moved! ";
> }
> }
> _________________________________________________________
>
> Lets say the HTML from that sends data to this script has 3 upload forms
> that get send to $_FILES, would I access the data by modifying the following
> line from the above example:
> ...
> foreach($_FILES[' UPLOADIMAGE1 '] as $file_name => $file_array) {
> ...
>
> ...
> foreach($_FILES[' UPLOADIMAGE2 '] as $file_name => $file_array) {
> ...
>
> ...
> foreach($_FILES[' UPLOADIMAGE3 '] as $file_name => $file_array) {
> ...
>
> Thanks for reading!
> Matt Cheezoid
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
Your foreach does exactly what you are asking.
foreach($_FILES as $file_name => $file_array)
The keys in $_FILES are the in your form.
If you have 3 files... then count( $_FILES ) should be 3
--
Martin Scotta
--000325554c7e4d447604781a1780--
RE: Multiple file upload
am 11.11.2009 16:51:19 von Huy Nguyen
Do you mean 3 forms, each having a file upload input? Or 1 form with 3 fil=
e upload inputs?
If you have 3 forms, then the user can only submit one form at a time. So =
your $_FILES would contain only one file.
If you have one form with 3 file upload, it depends on if they are the same=
name for the file input - whether they all are "UPLOADIMAGE[]", or each on=
e is "UPLOADIMAGE1", "UPLOADIMAGE2", "UPLOADIMAGE3", etc.
-----Original Message-----
From: Matthew Croud [mailto:matt@obviousdigital.com]=20
Sent: Wednesday, November 11, 2009 9:10 AM
To: PHP General list
Subject: Multiple file upload
Dear lords of PHP,
I have a working image upload script that meets all my needs,
My question is I need to upload multiple images using the same form,
This is the PHP part I have so far, largely taken from a book:
_________________________________________________________
if (is_uploaded_file($file_array["tmp_name"])) {
move_uploaded_file($file_array["tmp_name"], "$file_dir/".=20
$file_array["name"]) or die ("Couldn't copy");
echo "file was moved! ";
}
}
_________________________________________________________
Lets say the HTML from that sends data to this script has 3 upload =20
forms that get send to $_FILES, would I access the data by modifying =20
the following line from the above example:
....
foreach($_FILES[' UPLOADIMAGE1 '] as $file_name =3D> $file_array) {
....
....
foreach($_FILES[' UPLOADIMAGE2 '] as $file_name =3D> $file_array) {
....
....
foreach($_FILES[' UPLOADIMAGE3 '] as $file_name =3D> $file_array) {
....
Thanks for reading!
Matt Cheezoid
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
RE: Multiple file upload
am 11.11.2009 18:08:11 von TedD
Hi:
This is one way to do it:
http://php1.net/c/multi-uploads/index.php
You can either give the user defined "slots" for them to fill, or
not, or give them a button to add another "Choose File" button.
After you get the user information, then you can go through upload,
scrub, and approve the data before doing anything with it.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: RE: Multiple file upload
am 11.11.2009 18:34:22 von Phpster
On Wed, Nov 11, 2009 at 12:08 PM, tedd wrote:
> Hi:
>
> This is one way to do it:
>
> http://php1.net/c/multi-uploads/index.php
>
> You can either give the user defined "slots" for them to fill, or not, or
> give them a button to add another "Choose File" button.
>
> After you get the user information, then you can go through upload, scrub=
,
> and approve the data before doing anything with it.
>
> Cheers,
>
> tedd
>
> --
> -------
> http://sperling.com =A0http://ancientstones.com =A0http://earthstones.com
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>