mysql_query('INSERT INTO the_table (name,content) 
VALUES(".$HTTP_POST_FILES['ImgFile']['name'],',',
            
mysql_escape_string(implode('',file($HTTP_POST_FILES['ImgFile']['tmp_name']))).');');

you can use addslashes also but mysql_escape_string is safer.

Regards,
Andrey Hristov
----- Original Message ----- 
From: "phantom" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, December 06, 2001 12:48 PM
Subject: [PHP] Storing Img Binary in MySQL


> I want to store the image binary data in a MySQL Blob field.  So I
> created a simple form that prompted the client for an image file that
> would be uploaded to the server.
> 
> The server takes the file and gets the following data, assuming ImgFile
> is the name of the uploaded image.
> 
>   $ImgTitle = $HTTP_POST_FILES['ImgFile']['name'];
>   $ImgType = $HTTP_POST_FILES['ImgFile']['type'];
>   $ImgSize = $HTTP_POST_FILES['ImgFile']['size'];
> 
> When I go to save $ImgFile into MySQL is is actually saving the name of
> the temporary location of that file on my server and not the binary data
> that compose that image.  This does not surprise I knew this much at
> least.
> 
> So how do I get the Binary DATA to save and not the temp file location?
> 
> Thx.
> 
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
> 
> 


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to