RE: [PHP] help with code not wrking
| From: | Instruct ICC | Date: | Wed, 24 Oct 2007 19:50:20 +0000 |
| Subject: | RE: [PHP] help with code not wrking | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-263601@lists.php.net to get a copy of this message | ||
> From: Joey@Web56.Net
> To: php-general@lists.php.net
> Date: Wed, 24 Oct 2007 15:27:28 -0400
> Subject: [PHP] help with code not wrking
>
> Hi all,
>
>
>
> I have inherited a problem script from a client, and it's a simple upload
> function.
>
> The problem is that while the image is being uploaded and saved as the same
> name it was uploaded as, it's not writing to the table the file name for
> display reference so it's like there is no picture.
>
>
>
> I appreciate any help you can provide.
>
>
>
> Thanks!
>
>
> Joey
>
>
>
>
>
>
>
> include ("sesion_admin.php");
>
> include("../contentdb.php");
>
>
>
> $res_state=mysql_query("select * from states where 1 order by state");
>
> $id = $_GET["id"];
>
>
>
> echo "ID: " . $id . "IDL: " . $local_id . " Photo: " .
> $userfile . " [B4
> Upload]<br>";
>
>
>
> $p_proceso = $_POST["p_proceso"];
>
>
>
> if($p_proceso=="borrar"){
>
>
>
> $query_editar ="update Basic_Info set photo='' where Id=$id ";
>
> mysql_query($query_editar);
>
> }
>
>
>
> if($p_proceso=="upload"){
>
>
>
>
>
> $UPLOAD = fopen($userfile, "r" );
>
> $contents = fread($UPLOAD,$userfile_size);
>
> fclose($UPLOAD);
>
> $SAVEFILE = fopen("../photos/".$userfile, "wb" );
>
> fwrite( $SAVEFILE, $contents,$userfile_size);
>
> fclose( $SAVEFILE );
>
>
>
>
>
> #$query_editar ="update Basic_Info set photo='$userfile' where Id=$id ";
>
> mysql_query($query_editar);
>
> }
What is "$userfile"?
Are you using "$_FILES"? http://php.he.net/manual/en/features.file-upload.php
$_FILES['userfile']['name']
The original name of the file on the client machine.
$_FILES['userfile']['tmp_name']
The temporary filename of the file in which the uploaded file
was stored on the server.
And don't forget to set the HTML form tag's enctype="multipart/form-data"
_________________________________________________________________
Windows Live Hotmail and Microsoft Office Outlook – together at last. Get it now.
http://office.microsoft.com/en-us/outlook/HA102225181033.aspx?pid=CL100626971033