• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

Storing JPEG file as binary into mysql database step-by-step guide ?

Any particular reason you want to store the binary in the database.
You're probably better off storing a path to the file.
 
I think he means instructions on how to use some kind of language like PHP or ASP to insert a JPEG into a mysql db as a BLOB. I've recently decided I need to do something similar.

Here's one justification for doing so over just storing the path: Filenames. I have to separately figure out a way of providing a mechanism for renaming filenames uniquely upon uploading to the server to ensure that I don't overwrite a file. I also have a lot of files cluttering my directories.

Storing them as binary objects in the database would eliminate that hassle, and assuming that it's not as much of a hassel to get it in there in the first place, could prove to be a more effective option.

But I, as well, have been having difficulty finding a guide for this that actually works.
 
Originally posted by: xirtam
I think he means instructions on how to use some kind of language like PHP or ASP to insert a JPEG into a mysql db as a BLOB. I've recently decided I need to do something similar.

in perl:

$image = $database->quote($image);
$action = $database->prepare(qq~INSERT INTO images VALUES($image);~);
$action->execute;

Here's one justification for doing so over just storing the path: Filenames. I have to separately figure out a way of providing a mechanism for renaming filenames uniquely upon uploading to the server to ensure that I don't overwrite a file. I also have a lot of files cluttering my directories.

Also in perl, how to rename your files to avoid overwriting:

$filename =~ /^(.*)\.([^.]+)$/;
$name = $1;
$ext = $2;
$count = '';
while(-e "$name$count.$ext"){
$count++;
}

$filename = "$name$count.$ext";
 
Hi,

I agree with Xirtam that putting image files into database can be managed easily ! I also have a lot of files cluttering my directories. So any source out there can guide us to insert picture file into mysql database ? Thanks !

larva
 
Originally posted by: larva
Hi,

I agree with Xirtam that putting image files into database can be managed easily ! I also have a lot of files cluttering my directories. So any source out there can guide us to insert picture file into mysql database ? Thanks !

larva


OK, I think I'm about done with this thread....
 
Back
Top