Re: uploading a file from a form

From: Date: Mon, 28 Jul 2003 14:43:39 +0000
Subject: Re: uploading a file from a form
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-157185@lists.php.net to get a copy of this message
Everything is in the manual: http://www.php.net/features.file-upload Amanda McComb wrote:
I'm not sure what that means...how do I use it, and where? On Fri, 25 Jul 2003, Marek Kilimajer wrote:
Don't you need to use $HTTP_POST_FILES array because you have register_globals off? Amanda McComb wrote:
I am having a problem with uploading a file from a form. I changed the permission on the directory, but I am still getting an error. Here is my error: Copy failed./home/vencel/www/images/apt/company_logo/14Update Failed! It looks like it's not finding the file type. Here is my code: <? include("../includes/database.php"); ?> <? $long_path = "/home/vencel/www/images/apt/"; $short_path = "../images/apt/"; if (($REQUEST_METHOD=='POST')) { for(reset($HTTP_POST_VARS);
                     $key=key($HTTP_POST_VARS);
                     next($HTTP_POST_VARS)) {
        $this = addslashes($HTTP_POST_VARS[$key]);
        $this = strtr($this, ">", " ");
        $this = strtr($this, "<", " ");
        $this = strtr($this, "|", " ");
        $$key = $this;
} //Check for form fields, insert them. //Pull out the id auto-incremented from previous insert. //Check to see if a full-sized photo was uploaded if ($photo == "none") { echo "No photo."; } else {
     $end = strrchr($photo_name, ".");
echo $end;
     $new_photo_name = $company_id[0] . $end;
        if (!@copy($photo, $long_path . "company_logo/" . $photo_name)) {
         echo "Copy failed.";
         echo $long_path . "company_logo/" . $photo_name;
echo $new_photo_name;
     } else {
       $long_photo_path = $long_path . "company_logo/" . $new_photo_name;
       $photo_path = $short_path . "company_logo/" . $new_photo_name;
          if (!@rename($long_path . "logo/" . $photo_name,
          $long_photo_path)){
          echo "Full sized photo not renamed.";
       }
     }
} $add_image_query .= "UPDATE apt_company_t set company_logo_path='$photo_path', "; $add_image_query .= "WHERE company_cd = $company_id[0]";
        mysql_query($add_image_query) or die("Update Failed!");
           } } ?>
<FORM METHOD="post" ACTION=<? echo $PHP_SELF ?>> <table> <TR> <td colspan = 2><B>Use the <i>Browse</i> button to locate your file on your computer or local network.</B></td></tr>
                    <tr>
<td>Company Logo File:      </td><td><input type="file" name="photo"
size="30"></td></tr> <tr> <td colspan=2 align=center><INPUT TYPE="submit" VALUE="Add"></td> </tr> </table> </FORM> Any ideas?
-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php


« previous php.general (#157185) next »