The version is PHP Version 4.2.3.

On Tue, 29 Jul 2003, Tom Rogers wrote:

> Hi,
> 
> Friday, July 25, 2003, 1:48:50 AM, you wrote:
> AM> I am having a problem with uploading a file from a form.  I changed the
> AM> permission on the directory, but I am still getting an error.  Here is my
> AM> error:
> 
> AM> Copy failed./home/vencel/www/images/apt/company_logo/14Update Failed!
> 
> AM> It looks like it's not finding the file type.  Here is my code:
> 
> AM> <? include("../includes/database.php"); ?>
> AM> <?
> AM> $long_path = "/home/vencel/www/images/apt/";
> AM> $short_path = "../images/apt/";
> 
> AM> if (($REQUEST_METHOD=='POST')) {
> AM>    for(reset($HTTP_POST_VARS);
> AM>                       $key=key($HTTP_POST_VARS);
> AM>                       next($HTTP_POST_VARS)) {
> AM>          $this = addslashes($HTTP_POST_VARS[$key]);
> AM>          $this = strtr($this, ">", " ");
> AM>          $this = strtr($this, "<", " ");
> AM>          $this = strtr($this, "|", " ");
> AM>          $$key = $this;
> AM>    }
> 
> 
> AM> //Check for form fields, insert them.
> 
> AM> //Pull out the id auto-incremented from previous insert.
>   
> 
> AM> //Check to see if a full-sized photo was uploaded
> AM>  if ($photo == "none") { 
> AM>     echo "No photo.";
> AM>     } else {
> AM>       $end = strrchr($photo_name, ".");
> AM> echo $end;
> AM>       $new_photo_name = $company_id[0] . $end;
>     
> AM>       if ([EMAIL PROTECTED]($photo, $long_path . "company_logo/" . $photo_name)) 
> {
> AM>           echo "Copy failed.";
> AM>           echo $long_path . "company_logo/" . $photo_name;
> AM> echo $new_photo_name;
>     
> AM>       } else {
> AM>         $long_photo_path = $long_path . "company_logo/" . $new_photo_name;
> AM>         $photo_path = $short_path . "company_logo/" . $new_photo_name;
>     
> AM>         if ([EMAIL PROTECTED]($long_path . "logo/" . $photo_name,
> AM>            $long_photo_path)){
> AM>            echo "Full sized photo not renamed.";
> AM>         }
> AM>       }
> AM>     }
> AM>     $add_image_query .= "UPDATE apt_company_t set
> AM> company_logo_path='$photo_path', ";
> AM>     $add_image_query .= "WHERE company_cd = $company_id[0]";
>       
> AM>     mysql_query($add_image_query) or die("Update Failed!");
>       
>     
> AM>     } 
> } ?>>
> AM> <FORM METHOD="post" ACTION=<? echo $PHP_SELF ?>>
> AM> <table>
> AM> <TR>
> AM> <td colspan = 2><B>Use the <i>Browse</i> button to locate your file on
> AM> your computer or local network.</B></td></tr>
>                      
> AM> <tr>
> AM> <td>Company Logo File:      </td><td><input type="file" name="photo"
> size="30">></td></tr>
> 
> AM> <tr>
> AM> <td colspan=2 align=center><INPUT TYPE="submit" VALUE="Add"></td>
> AM> </tr>
> AM> </table>
> AM> </FORM>
> 
> AM> Any ideas?
> 
> The first thing is to add ENCTYPE="multipart/form-data" to the form
> tag.
> 
> <FORM ENCTYPE="multipart/form-data" METHOD="post" ACTION=<? echo $PHP_SELF ?>>
> 
> Then the rest will depend on what version of php you have.
> 
> It may be worth doing print_r($_FILES); to see if that is available.
> 
> -- 
> regards,
> Tom
> 
> 
> -- 
> 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

Reply via email to