Yes u can upload multiple files at once.
In the form you must use:
<input type="file" name="userfile[]">.
Se userfile[] like an array.
In the form tag:
 enctype="multipart/form-data"

The PHP script which recieves the file:
Just walk the $userfile array and copy the file or move.

Sample:
for ($i=0;$i<count($userfile);$i++){
        $mydest = "/some/path" . $userfile_name[$i];
        copy($userfile[$i],$mydest);
}


This should work fine.


-Mike


On Sat, 2 Nov 2002, [iso-8859-1] toby z wrote:

> Date: Sat, 2 Nov 2002 11:40:32 +0000 (GMT)
> From: "[iso-8859-1] toby z" <[EMAIL PROTECTED]>
> To: marcelo <[EMAIL PROTECTED]>, [EMAIL PROTECTED]
> Subject: Re: [PHP-WIN] uploading help please
>
> hi marcelo
>
> 1st
> i don think u can upload 2 filez simultaneosly
>
>
> 2nd
> <form enctype=\"multipart/form-data\" action=up.php
> method=post>
> is what u do when u wanna upload A file
>
>
> 3rd
> when u see Array displayed istead ur variable it means
> the variable aint bein piked by the page or the query
>
>
> check ur code and the variables passed
>
> hope i ve helped ....
>
> good luck
>
> toby
>
> --- marcelo <[EMAIL PROTECTED]> wrote: > Hi
> need some help please
> >
> >  What is wrong with my code?
> >
> >  it is supposed to upload 2 files but instead gives
> > me this error
> >
> >  Warning: Unable to open 'Array' for reading
> >
> > The code:
> >
> > <html>
> > <head>
> > <title>O Leme upload</title>
> > <meta http-equiv="Content-Type" content="text/html;
> > charset=iso-8859-1">
> > </head>
> >
> > <body>
> >
> > <?php
> >
> >
> >
> > $PHP_SELF = $_SERVER['PHP_SELF'];
> > $page = $_REQUEST['page'];
> > $origem = $_FILES['origem'];
> > $origem2 = $_FILES['origem2'];
> >
> >
> >
> > switch($page)
> > {
> >  case "um":
> >     um($origem ,$origem2);
> >  break;
> >  case "dois":
> >   dois($origem, $origem2);
> >  break;
> >
> >  default:
> >   um($origem ,$origem2);
> >  break;
> > }
> >
> > function um($origem ,$origem2)
> >
> >
> > {
> >
> > ?>
> >
> >
> >
> > <title>Jornal O Leme</title>
> > <meta http-equiv="Content-Type" content="text/html;
> > charset=iso-8859-1">
> > </head>
> >
> > <body bgcolor="#006699">
> > <table width="100%" border="0" cellpadding="0"
> > cellspacing="0">
> >   <!--DWLayoutTable-->
> >   <tr>
> >     <td width="100%" height="70" valign="top"><img
> > src="test.jpg"
> > width="600" height="120">
> >     </td>
> >   </tr>
> >   <tr>
> >     <td height="262" valign="top"><p>&nbsp;</p>
> >       <form method="post"  action="<?php $PHP_SELF
> > ?>"
> > enctype="multipart/form-data">
> >         <table width="75%" border="0" align="center"
> > bgcolor="#FFFFFF">
> >           <tr>
> >             <td width="23%"><div
> > align="center"><font face="BankGothic Md
> > BT">
> >                 </font></div></td>
> >             <td width="77%" bgcolor="#FFFFFF">&nbsp;
> > </td>
> >           </tr>
> >           <tr>
> >             <td><div align="center"></div></td>
> >             <td bgcolor="#FFFFFF">&nbsp; </td>
> >           </tr>
> >           <tr>
> >             <td><div align="center"></div></td>
> >             <td bgcolor="#FFFFFF">&nbsp; </td>
> >           </tr>
> >           <tr>
> >             <td><div align="left"><strong>Imagem
> > pequena</strong></div></td>
> >             <td bgcolor="#FFFFFF"> <input
> > type=hidden name=MAX_FILE_SIZE
> > value=102400>
> >               <input type="File" name="origem">
> > </td>
> >           </tr>
> >           <tr>
> >             <td><div align="left"><strong>Imagem
> > grande</strong></div></td>
> >             <td bgcolor="#FFFFFF"><input type=hidden
> > name=MAX_FILE_SIZE
> > value=102400>
> >               <input type="File" name="origem2">
> > </td>
> >           </tr>
> >           <tr>
> >             <td><div align="center"></div></td>
> >             <td bgcolor="#FFFFFF">&nbsp; </td>
> >           </tr>
> >           <tr>
> >             <td>&nbsp;</td>
> >             <td>&nbsp;</td>
> >           </tr>
> >         </table>
> >         <p align="center">
> >           <input name="submit" type="submit"
> > value="Adicionar">
> >     <input type="hidden" name="page" value="dois">
> >       </form></p>
> >       </td>
> >   </tr>
> >   <tr>
> >     <td height="81" valign="top"><div
> > align="center">
> >         <p>&nbsp;</p>
> >         <p>
> >   <?php
> >
> >   include ('menu.php');
> >
> >   ?>
> >   &nbsp;</p>
> >       </div></td>
> >   </tr>
> > </table>
> >
> >
> > <?php
> >
> >
> >
> > }
> >
> >
> >
> >
> > function dois($origem, $origem2)
> >
> >
> > {
> > set_time_limit(60);
> >
> $path=(dirname($PATH_TRANSLATED))."../primeirapagina/";
> > $origem_name="pppv2.jpg";
> > $dest= $path.$origem_name;
> >
> > if (($origem <> "none") && ($origem <> "")){
> >    if (copy($origem,$dest)){;
> >
> >      } else {
> >       echo "directoria sem direitos de escrita
> > <br>";
> >       }
> > unlink ($origem);
> > }
> >
> > set_time_limit(60);
> >
> $path2=(dirname($PATH_TRANSLATED))."../primeirapagina/";
> > $origem2_name="ppv2.jpg";
> > $dest2= $path2.$origem2_name;
> >
> > if (($origem2 <> "none") && ($origem2 <> "")){
> >    if (copy($origem2,$dest2)){;
> >
> > } else {
> >       echo "directoria sem direitos de escrita
> > <br>";
> >       }
> > unlink ($origem2);
> > }
> >
> >
> >
> >
> > }
> >
> >
> >
> >
> >
> > ?>
> > </body>
> > </html>
> >
> >
> >
> >
> >
> === message truncated ===
>
> __________________________________________________
> Do You Yahoo!?
> Everything you'll ever need on one web page
> from News and Sport to Email and Music Charts
> http://uk.my.yahoo.com
>
> --
> PHP Windows Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>


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

Reply via email to