php-windows | 2003032
Date: 03/26/03
- Next message: Matt Babineau: "[PHP-WIN] cURL on WinXP, running ISAPI"
- Previous message: Afan Pasalic: "Re: [PHP-WIN] uploading files"
- In reply to: Afan Pasalic: "Re: [PHP-WIN] uploading files"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Sorry, there is some part of code you don't need (as $cat_id) - I just grab
it from activ file...
Afan
At 09:02 AM 3/26/2003 -0500, Afan Pasalic wrote:
>This is a code I use for uploading up to three images at same time. Works
>fine:
>
><?php
>
>$PHP_SELF = 'new_product.php';
>
>$query = "select name from categories where cat_id=$cat_id";
>$result = mysql_query($query, $db) or die ('Error: wrong query');
>$myrow = mysql_fetch_array($result);
>
>include('errors.php');
>$error = 'n';
>?>
>
><table width="700" border=0 cellpadding=10 cellspacing="0">
><tr>
><td width="550" align="left" valign="top">
><?php
>if($_POST[SubmitAdd])
>{
> if(empty($_POST[img_name]))
> {
> $error = 'y';
> print_error(123);
> }
>
> if($_FILES[var1][size] != 0)
> {
> if(!stristr($_FILES[var1][name], ".jpg"))
> {
> $error = 'y';
> print_error(125);// print: your file does not
> have .jpg extension
> }
> else
> {
> $NoOfImages = 1;
> }
> }
> else
> {
> $error = 'y';
> print_error(102);
> }
>
> if(!$_FILES[var2][size] == '0')
> {
> if(!stristr($_FILES[var2][name], ".jpg"))
> {
> $error = 'y';
> print_error(125);// print: your file does not
> have .jpg extension
> }
> else
> {
> $NoOfImages = 2;
> }
> }
>
> if($_FILES[var3][size] != '0')
> {
> if(!stristr($_FILES[var3][name], ".jpg"))
> {
> $error = 'y';
> print_error(125);// print: your file does not
> have .jpg extension
> }
> else
> {
> $NoOfImages = 3;
> }
> }
>
> if($error == 'n')
> {
> $img_name = $_POST[img_name];
> $img_name = eregi_replace('.jpg', '', $img_name);
> $img_name = stripslashes(eregi_replace(' ', '_',
> $img_name)).".jpg";
>
> for($i=1; $i<=$NoOfImages; $i++)
> {
> ${NewImage.$i} = $i."_".$img_name;
> $vars = "var".$i;
> copy($_FILES[$vars][tmp_name],
> "/home/fusionfurnituregallery.com/product_images/".${NewImage.$i});
> $NewImages .= "@@".${NewImage.$i};
> }
>
> if(is_uploaded_file($_FILES[var1][tmp_name]) or
> is_uploaded_file($_FILES[var2][tmp_name]) or
> is_uploaded_file($_FILES[var3][tmp_name])) { print_error(126); }
> else { $error = 'y'; print_error(127); }
> }
>}
>
>if(!$_POST[SubmitAdd] or $error != 'n')
>{
>?>
>
><form ENCTYPE=multipart/form-data action="<?php echo $PHP_SELF; ?>"
>name=qmform method=post>
><table border="0" cellspacing="0" cellpadding="1" width=300>
><tr>
><td align="left" valign="top">Product name:<br>
><input name=prod_name value="<?php echo $_POST[prod_name]; ?>" type=text
>size=30 style="border:1 solid; font-size: 10px;"><br><br></td>
></tr>
><tr>
><td align="left" valign="top">Product Ser.# <span
>style="font-size:10px;">(no space or spec. char.):</span><br>
><input name=img_name value="<?php echo $_POST[img_name]; ?>" type=text
>size=30 style="border:1 solid; font-size: 10px;"><br><br></td>
></tr>
><tr>
><td align="left" valign="top">Upload 1st image:<br>
><input name=var1 type=file size=30 style="border:1 solid; font-size:
>10px;"><br><br></td>
></tr>
><tr>
><td align="left" valign="top">Upload 2nd image:<br>
><input name=var2 type=file size=30 style="border:1 solid; font-size:
>10px;"><br><br></td>
></tr>
><tr>
><td align="left" valign="top">Upload 3rd image:<br>
><input name=var3 type=file size=30 style="border:1 solid; font-size:
>10px;"><br><br></td>
></tr>
><tr>
><td align=left valign="top">
><INPUT type=hidden name=MAX_FILE_SIZE value="<?php echo $my_max_file_size;
>?>">
><input type=submit name=SubmitAdd value=" Upload ! " style="border:1
>solid; font-size: 10px;"></td>
></tr></form>
></table>
>
>
>
>Afan
>
>
>At 09:45 AM 3/26/2003 +0100, Bobo Wieland wrote:
>>Is it possible to upload multiple files at once? ...In a form, using a
>>"file" input and being able to select more then one file?
>>
>>
>>.bobo
>>
>>
>>--
>>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
-- PHP Windows Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
- Next message: Matt Babineau: "[PHP-WIN] cURL on WinXP, running ISAPI"
- Previous message: Afan Pasalic: "Re: [PHP-WIN] uploading files"
- In reply to: Afan Pasalic: "Re: [PHP-WIN] uploading files"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

