Closed Thread Icon

Topic awaiting preservation: saving .jpg file in database and view them (Page 1 of 1) Pages that link to <a href="https://ozoneasylum.com/backlink?for=24648" title="Pages that link to Topic awaiting preservation: saving .jpg file in database and view them (Page 1 of 1)" rel="nofollow" >Topic awaiting preservation: saving .jpg file in database and view them <span class="small">(Page 1 of 1)</span>\

 
shalvi
Nervous Wreck (II) Inmate

From:
Insane since: Oct 2003

posted posted 01-11-2005 06:53

Hello,

I'm wondering to find out how to save a .jpg file in a database and show them in the web page? any good method and working example will help me a lot...

norm
Paranoid (IV) Inmate

From: [s]underwater[/s] under-snow in Juneau
Insane since: Sep 2002

posted posted 01-11-2005 07:03

Blob is the data type to set for the field to contain your jpegs. My blob upload/download scripts are on my work box and I at home right now, so I suggest that you use google and find a nice tutorial... or check out your php reference books.

Happy coding!

/* Sure, go ahead and code in your fancy IDE. Just remember: it's all fun and games until someone puts an $i out */

(Edited by norm on 01-11-2005 07:04)

Tyberius Prime
Paranoid (IV) Mad Scientist with Finglongers

From: Germany
Insane since: Sep 2001

posted posted 01-11-2005 08:49

actually, you should really think about doing this one, shalvi.
Storing your images in a database is going to be very very slow.
I did it once, and suprise, my otherwise very fast website would only output images with 6kb/s - welcome to modem land ;-).
Usually, I store just the paths in the database, and let the images sit as files somewhere.

So long,

->Tyberius Prime

I X I
Paranoid (IV) Inmate

From: beyond the gray sky
Insane since: Apr 2004

posted posted 01-11-2005 10:22

I was just playing around with the same thing on my website. I did it like TP is saying to

code:
$data = mysql_db_query("ixifx_net","SELECT * FROM image WHERE userID='$userID'");
echo "<table width=\"390\" border=\"1\">\n";
$Refresh = 0;
while ($AA = mysql_fetch_array($data)) {
$imgID = $AA["imgID"];
$imgURL = $AA["imgURL"];
$imgALT = $AA["imgALT"];
$imgDESC = $AA["imgDESC"];
if($Refresh == 0) {
echo " <tr>\n";
}
echo " <td width=\"25%\">\n";
echo " <a href=\"img/$userID/$imgURL\">\n";
echo " <img src=\"img/$userID/$imgURL\" alt=\"$imgALT\" border=\"0\">\n";
echo " </a>\n";
echo " $imgID\n";
echo " </td>\n";
$Refresh++;
if($Refresh == 4) {
echo " </tr>\n";
$Refresh = 0;
}
}
echo "</table>\n";
mysql_close();



www.ixifx.net/image.php?page=view&userID=88x31 to see it in action

the script isn't finished, I still need to work out uploading and thumbnails, but it works to an extent



Take your time, hurry up; the choice is yours just don't be late (Kurt Cobain)

[edit] I know I probably shouldn't be doing my echo statements like that all the time, but it helps me keep everything straight at the moment[/edit]

(Edited by I X I on 01-11-2005 10:47)

(Edited by I X I on 01-11-2005 13:23)

Skaarjj
Maniac (V) Mad Scientist

From: :morF
Insane since: May 2000

posted posted 01-11-2005 10:45

Yes, what TP said. Storing image files in your database is a needless waste of space, frankly. Better to have the files sitting in their own directory on your webserver and to reference their paths through your database.


Justice 4 Pat Richard

InI
Maniac (V) Mad Scientist

From: Somewhere over the rainbow
Insane since: Mar 2001

posted posted 01-11-2005 10:53

The poster has demanded we remove all his contributions, less he takes legal action.
We have done so.
Now Tyberius Prime expects him to start complaining that we removed his 'free speech' since this message will replace all of his posts, past and future.
Don't follow his example - seek real life help first.

DmS
Maniac (V) Inmate

From: Sthlm, Sweden
Insane since: Oct 2000

posted posted 01-11-2005 21:10

I've also kept to the principle of binary objects in the filesystem, path and meta data in the db.
Filesystem for files, database for data

However, I'm in a project right now where a lot of images are stored in the db primarily due to issues with propogating uploaded files over the 4 webservers that run the site and some other related things. this will eventually be solved by other responsible parties but to advance that I wonder if there are any benchmarks or similar available on this?
Ideally based on PHP/MySQL.

Thanx/Dan

{cell 260} {Blog}
-{ ?Computer games don?t affect kids; I mean if Pac-Man affected us as kids, we?d all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music.? (Kristian Wilson, Nintendo, Inc, 1989.) }-

« BackwardsOnwards »

Show Forum Drop Down Menu