pics?

Codes here !

Moderators: macek, egami, gesf

infomorelos
New php-forum User
New php-forum User
Posts: 14
Joined: Mon Jan 27, 2003 12:10 am
Location: Cuernavaca, Mexico

pics?

Postby infomorelos » Tue Feb 04, 2003 1:52 am

Hi,
can I put images into a MySQL table?
If so, which kind of field would that be?

Thank you in advance

User avatar
Oleg Butuzov
Last Samuray
Last Samuray
Posts: 831
Joined: Sun Jun 02, 2002 3:09 am

Postby Oleg Butuzov » Tue Feb 04, 2003 2:38 am

1) Yes you can
2) BLOB

Elena Mitovska
New php-forum User
New php-forum User
Posts: 13
Joined: Tue Nov 12, 2002 12:11 pm
Location: Ukraine
Contact:

Postby Elena Mitovska » Tue Feb 04, 2003 11:18 pm

One of the ways to insert image:
$data = "";
$userfile = $HTTP_POST_FILES['userfile']['tmp_name'];
//get file
$fp = fopen($userfile, "rb");
while(!feof($fp))
{
$data .= fread($fp, 1024);
}
fclose($fp);

$data = addslashes($data);
$data = addcslashes($data, "\0");

//insert image into database
$Query = "INSERT INTO imagesVALUES(".$item_no.",'$data')";

User avatar
Oleg Butuzov
Last Samuray
Last Samuray
Posts: 831
Joined: Sun Jun 02, 2002 3:09 am

Postby Oleg Butuzov » Tue Feb 04, 2003 11:28 pm

Helen, you forgot to say "thank you http://php.spb.ru"

he is author of the script =)


Return to “mySQL & php coding”

Who is online

Users browsing this forum: Bing [Bot] and 1 guest