[PHP] Multiple file upload

2009-11-11 Thread Matthew Croud

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].br/\n;
echo name: .$file_array[name].br/\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!br/;
}
}
_

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



Re: [PHP] Multiple file upload

2009-11-11 Thread Martin Scotta
On Wed, Nov 11, 2009 at 12:09 PM, Matthew Croud m...@obviousdigital.comwrote:

 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].br/\n;
echo name: .$file_array[name].br/\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!br/;
}
 }
 _

 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 input type=file / in your form.
If you have 3 files... then count( $_FILES ) should be 3


-- 
Martin Scotta


Re: [PHP] multiple file upload, yet again

2003-02-10 Thread David T-G
Jason --

...and then Jason Wong said...
% 
% On Monday 10 February 2003 08:36, David T-G wrote:
% 
%  Hmmm...  I haven't yet been able to download it, but I was pointed to a
%  live page (tech.indymedia.org/publish.php3) only to find that it has
%  multiple boxes for multiple files, which I can already do.  Nothing that
...
% 
% You probably already know this -- HTML does not allow for the type of multiple 

Ah.  No, actually I didn't know it, though I suspected it.

Thanks for the clarification.


% uploads that you seek. Any solutions out there will be based on 
% 'non-standard' technology -- javascript, java or some activex control.

Yeah.  So I suppose that must be how Javier did it, too.  Again, if I
could get on to hotmail I could see how they do it and copy it :-)


Thanks a *bunch*  HAND

:-D
-- 
David T-G  * There is too much animal courage in 
(play) [EMAIL PROTECTED] * society and not sufficient moral courage.
(work) [EMAIL PROTECTED]  -- Mary Baker Eddy, Science and Health
http://justpickone.org/davidtg/  Shpx gur Pbzzhavpngvbaf Qrprapl Npg!




msg96401/pgp0.pgp
Description: PGP signature


Re: [PHP] multiple file upload, yet again

2003-02-09 Thread Gurhan Ozen
Hi David, 
I know that there is an php application doing multiple file uploading at
once which is open source..
The application is san franscisco indymedia's news publishing system.
You might wanna download it at: http://tech.sfimc.net/download.php and
scrutinize the source code.. I am very sure their coders will help you
in anyway as well.
I hope this helps..
Gurhan

On Sun, 2003-02-09 at 01:18, David T-G wrote:
 Hi, all --
 
 I realize that this has probably been beaten to death, and I've watched
 with some excitement the recent crop of discussions of multiple file
 uploads, but only to be disappointed.
 
 I've read in detail the archives and seen countless statements that one
 cannot upload multiple files in one selection, requiring instead that you
 have multiple input boxes and then a single submit button if you want.
 I've also see, however, a few mentions of a script or a class that *do*
 allow you to select multiple files in the browse window and make
 reference to hotmail multiple attachment uploads.
 
 Does anyone know how to do this?  I would like for my users to be able to
 select their files in one swell foop, perhaps even all in the directory,
 rather than having to click repeatedly for each file to upload.
 
 I even tried making myself a hotmail account so I could send myself mail
 and try to upload multiple files and then look at the HTML source :-) but
 the server had some problem or other and I couldn't get set up.  Well, I
 didn't really want an account anyway.
 
 
 TIA  HAND
 
 :-D
 -- 
 David T-G  * There is too much animal courage in 
 (play) [EMAIL PROTECTED] * society and not sufficient moral courage.
 (work) [EMAIL PROTECTED]  -- Mary Baker Eddy, Science and Health
 http://justpickone.org/davidtg/  Shpx gur Pbzzhavpngvbaf Qrprapl Npg!
 




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] multiple file upload, yet again

2003-02-09 Thread David T-G
Gurhan, et al --

...and then Gurhan Ozen said...
% 
% Hi David, 

Hi!


% I know that there is an php application doing multiple file uploading at
% once which is open source..

Cool!


% The application is san franscisco indymedia's news publishing system.
% You might wanna download it at: http://tech.sfimc.net/download.php and

Hmmm...  I haven't yet been able to download it, but I was pointed to a
live page (tech.indymedia.org/publish.php3) only to find that it has
multiple boxes for multiple files, which I can already do.  Nothing that
allows multiple files with shift-clicking or the like...

If only hotmail would let me sign up!  grr...  Then i could see if it
really does it and how...


% scrutinize the source code.. I am very sure their coders will help you
% in anyway as well.

Heh.  I haven't found any yet, though the #tech channel has been very
nice about being unhelpful.


% I hope this helps..
% Gurhan


Thanks anyway  HAND

:-D
-- 
David T-G  * There is too much animal courage in 
(play) [EMAIL PROTECTED] * society and not sufficient moral courage.
(work) [EMAIL PROTECTED]  -- Mary Baker Eddy, Science and Health
http://justpickone.org/davidtg/  Shpx gur Pbzzhavpngvbaf Qrprapl Npg!




msg96348/pgp0.pgp
Description: PGP signature


Re: [PHP] multiple file upload, yet again

2003-02-09 Thread Jason Wong
On Monday 10 February 2003 08:36, David T-G wrote:

 Hmmm...  I haven't yet been able to download it, but I was pointed to a
 live page (tech.indymedia.org/publish.php3) only to find that it has
 multiple boxes for multiple files, which I can already do.  Nothing that
 allows multiple files with shift-clicking or the like...

 If only hotmail would let me sign up!  grr...  Then i could see if it
 really does it and how...


 % scrutinize the source code.. I am very sure their coders will help you
 % in anyway as well.

You probably already know this -- HTML does not allow for the type of multiple 
uploads that you seek. Any solutions out there will be based on 
'non-standard' technology -- javascript, java or some activex control.

-- 
Jason Wong - Gremlins Associates - www.gremlins.biz
Open Source Software Systems Integrators
* Web Design  Hosting * Internet  Intranet Applications Development *
--
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
--
/*
I'm pretending I'm pulling in a TROUT!  Am I doing it correctly??
*/


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] multiple file upload, yet again

2003-02-08 Thread David T-G
Hi, all --

I realize that this has probably been beaten to death, and I've watched
with some excitement the recent crop of discussions of multiple file
uploads, but only to be disappointed.

I've read in detail the archives and seen countless statements that one
cannot upload multiple files in one selection, requiring instead that you
have multiple input boxes and then a single submit button if you want.
I've also see, however, a few mentions of a script or a class that *do*
allow you to select multiple files in the browse window and make
reference to hotmail multiple attachment uploads.

Does anyone know how to do this?  I would like for my users to be able to
select their files in one swell foop, perhaps even all in the directory,
rather than having to click repeatedly for each file to upload.

I even tried making myself a hotmail account so I could send myself mail
and try to upload multiple files and then look at the HTML source :-) but
the server had some problem or other and I couldn't get set up.  Well, I
didn't really want an account anyway.


TIA  HAND

:-D
-- 
David T-G  * There is too much animal courage in 
(play) [EMAIL PROTECTED] * society and not sufficient moral courage.
(work) [EMAIL PROTECTED]  -- Mary Baker Eddy, Science and Health
http://justpickone.org/davidtg/  Shpx gur Pbzzhavpngvbaf Qrprapl Npg!




msg96291/pgp0.pgp
Description: PGP signature


[PHP] multiple file upload

2002-11-14 Thread Funk-XL
Is it possible to upload multiple files at once without selecting each file
with seperate form fields?



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] multiple file upload

2002-11-14 Thread Funk-XL
Hi All,

Is it posible to do multiple file upload without selecting each file manual
in multiple form fields?

Rob



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] multiple file upload

2002-11-14 Thread John W. Holmes
 Is it posible to do multiple file upload without selecting each file
 manual
 in multiple form fields?

No.

---John Holmes...



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] multiple file upload

2002-11-14 Thread Justin French
Hi,

on 14/11/02 8:12 PM, Funk-XL ([EMAIL PROTECTED]) wrote:

 Is it posible to do multiple file upload without selecting each file manual
 in multiple form fields?

Nope.  Only way I can think of would be if the files were
pre-zipped/stuffed/gzipped/etc, AND if you were able to decompress on the
server, which would only be possible for some compression types.

I'm thinking there MIGHT be some way with a hugely complex Java (not
javascript) program, but I'm no expert.



Justin French

http://Indent.com.au
Web Developent  
Graphic Design



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] multiple file upload

2002-11-14 Thread Jason Wong
On Thursday 14 November 2002 18:12, Funk-XL wrote:
 Hi All,

 Is it posible to do multiple file upload without selecting each file manual
 in multiple form fields?

Nope.

-- 
Jason Wong - Gremlins Associates - www.gremlins.biz
Open Source Software Systems Integrators
* Web Design  Hosting * Internet  Intranet Applications Development *

/*
O Lord, grant that we may always be right, for Thou knowest we will
never change our minds.
*/


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] multiple file upload

2002-11-14 Thread Marek Kilimajer
Don't get mistaken. Sure it is possible:

input type=file name=file[]
input type=file name=file[]
input type=file name=file[]

this will give you 
$_FILES['file']['name'][0],$_FILES['file']['name'][1],$_FILES['file']['name'][2],
the same for [type],[tmp_name] and [size]


Funk-XL wrote:

Hi All,

Is it posible to do multiple file upload without selecting each file manual
in multiple form fields?

Rob



 



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] multiple file upload

2002-11-14 Thread Marek Kilimajer
Sorry, now I read your question thoroughly, no this is not possible

Funk-XL wrote:


Hi All,

Is it posible to do multiple file upload without selecting each file manual
in multiple form fields?

Rob



 



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] multiple file upload

2002-11-14 Thread Edward Peloke
I am probably missing something here, how would you select each file you
want?  Do you mean just using one form field?  Seems like this would be ugly
if it was even possible which it looks like it is not.  I have a script that
uses multiple form fields but one upload button and then just loops through
each picture uploading it...this is what you will probably have to do.

Eddie

-Original Message-
From: Marek Kilimajer [mailto:kilimajer;webglobe.sk]
Sent: Thursday, November 14, 2002 8:32 AM
To: PHP
Subject: Re: [PHP] multiple file upload


Sorry, now I read your question thoroughly, no this is not possible

Funk-XL wrote:

Hi All,

Is it posible to do multiple file upload without selecting each file manual
in multiple form fields?

Rob







--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] Multiple File Upload

2001-08-03 Thread Arne

Hi,

I want to upload multiple files in one step. I know how to handle the things
on PHP side, but how can I select more than one file in the select box. It
does not work with:
FORM ENCTYPE=multipart/form-data ACTION=_URL_ METHOD=POST
INPUT NAME=userfile TYPE=file/FORM

I can only select one file. Is there a possibillity to select more, like in
windows explorer?



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] multiple file upload..

2001-02-26 Thread John LYC

i have a situation. i hope im clear abt this.
i need to post multiple set of data elements into php.
each set consists of  data elements of text, textarea, radio buttons,
checkboxes and even a file(image).
most fields are optional.
all sets are not subset of each other but belongs to the same universal
set.

all these sets of data elements are posted using one single form
and this form will only display at most 3 set of form elements input at
one time.
the user of course can do more than 3. by declaring how many he/she
wants before landing on this page.
meaning if user chose 4 , the form display 3 sets. User submits and the
form will again appear with one set this time.

the form will not update the database till the user finishes number of
sets he/she had declared.
i  only have problem with the (image) file data element.
this image file.. if existing , is stored into the database as blob.

questions:
1. if file is not declared, what does the file elements holds?... i
sometimes get null value, sometimes get "none"
2. does my logic works.. coz usually the file elements in the last form
post will work.. but the previous will be corrupted.
3. i try using file input elements as arrays.. meaning input type=file
name=filearr[x].. doesn't work?
4.anyone know how to  work around this... does anyone encounter problem
like these before?

thanks for any help
john

here's what i do ignore any syntax error. this is just a stripdown
version of the code.. it is just for putting across the logic..


/

if($submit)
{
//loop to run thur all QuestDiax and convert into characters.
for ($j=0; $i  $index; $i++,$j++)
{
$filestr = "QuestDia".$j;
if($$filestr)
$diagram[$j] = addslashes(fread(fopen($$filestr,"r"),
filesize($$filestr)));
 }//for

//insert into database

}//if submit




print "form enctype=".." method = post ";

for($i=0; $i  3; $i++)
{
   print "input type=\"file\" name=\"QuestDia".$i."\"";
}//for

print "/form";





-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] multiple file upload..

2001-02-26 Thread Yasuo Ohgaki

snip
 questions:
 1. if file is not declared, what does the file elements holds?... i
 sometimes get null value, sometimes get "none"

I get following output with PHP4.0.4pl1 w/ Linux
(I set php.ini to store uploaded files info to $HTTP_UPLOAD_FILES.
You will get different output if you don't)

- OUTPUT - when files to upload are not specified --
Key = userfile, Val = Array

a.. Key = name, Val = Array
a.. Key = 0, Val =
a.. Key = 1, Val =
a.. Key = type, Val = Array
a.. Key = 0, Val = application/octet-stream
a.. Key = 1, Val = application/octet-stream
a.. Key = tmp_name, Val = Array
a.. Key = 0, Val = none
a.. Key = 1, Val = none
a.. Key = size, Val = Array
a.. Key = 0, Val = 0
a.. Key = 1, Val = 0
-

- CODE - file_upload.php ---
html
head
titleFile Upload Test/title
meta http-equiv="Content-Type" content="text/html; charset=EUC-JP"
/head

body bgcolor="#FF"
?php
// Data about Uploaded Files are stored in array in
$HTTP_POST_FILES["input_name"]
while(list($k,$v) = each($HTTP_POST_FILES)) {
 print("Key = $k,   Val = $v br\n");
 if (is_array($v)) {
  while(list($tk, $tv) = each($v)) {
   print("liKey = $tk, Val = $tvbr\n");
   if (is_array($tv)) {
while(list($ttk, $ttv) = each($tv)) {
 print("liKey = $ttk, Val = $ttvbr\n");
}
   }
  }
 }
}
?

form enctype="multipart/form-data" action="file_upload.php" method="post"
input type="text" name"text" value="TEST"
input type="hidden" name="MAX_FILE_SIZE" value="1"
!-- Do any browsers care about MAX_FILE_SIZE? --
Send this file: input type="file" name="userfile[]"
Send this file: input type="file" name="userfile[]"
input type="submit" value="Send File"
/form
/body
/html
---

 2. does my logic works.. coz usually the file elements in the last form
 post will work.. but the previous will be corrupted.

I cannot understand what you mean well

 3. i try using file input elements as arrays.. meaning input type=file
 name=filearr[x].. doesn't work?

See the code and output, it works. (at least when PHP stores uploaded file
info to $HTTP_UPLOAD_FILES. Does not work w/o it?)

 4.anyone know how to  work around this... does anyone encounter problem
 like these before?

Did you copy temp file? It will be deleted.

Regards
--
Yasuo Ohgaki

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]