Re: Upload multiple files?
| From: | colbey at dreamwerx dot net | Date: | Fri, 29 Aug 2003 21:55:32 +0000 |
| Subject: | Re: Upload multiple files? | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-30243@lists.php.net to get a copy of this message | ||
Very simple...
Call you files being uplaoded file1, file2, fileX in the HTML form..
[html]
<form method="post" action="uploadprocess.php"
enctype="multipart/form-data">
<input type="file" name="file1" size="20">
<input type="file" name="file2" size="20">
<input type="file" name="file3" size="20">
<input type="submit" name="submit" value="submit">
</form>
[/html]
Then process with code like this:
[code]
$STARTFILE = 1;
$ONFILE = "file" . $STARTFILE;
while (isset($HTTP_POST_FILES["$ONFILE"])) {
// Try!
$SrcPathFile = $HTTP_POST_FILES["$ONFILE"]["tmp_name"];
$SrcFileType = $HTTP_POST_FILES["$ONFILE"]["type"];
$DstFileName = $HTTP_POST_FILES["$ONFILE"]["name"];
// File Processing
if (file_exists($SrcPathFile)) {
// handle it
}
$STARTFILE ++;
$ONFILE = "file" . $STARTFILE;
}
[/code]
You may want to update the $HTTP_POST_FILES -> $_FILES depending on PHP
version, etc...
Code from: http://php.dreamwerx.net/forums/viewtopic.php?t=6
good luck..
On Fri, 29 Aug 2003, Chris Payne wrote:
> Hi there everyone,
>
> I have created a newsletter system where you can do lots of nice things, one of the things is
> to be able to upload your images for the newsletter via the interface, unfortunately you have to do
> them 1 at a time. Is it possible to be able to select multiple images in 1 go?
>
> The image info is stored in a DB and the images themselves are on the server, this way I can do
> lots of nice things to manage the images that have been uploaded without having to access the
> filesystem too much (I love PHP and MySQL, makes it so easy).
>
> Thanks everyone.
>
> Chris