-1

I actually am working on a website having heavy sized images. So while i'm trying to store those images in the Mysql table using LONGBLOB, it is still throwing up the error about the size. Once the images are stored in the database, I want to fetch them in the website using PHP.

Can anyone one tell me how to go about that and also if there are any other alternatives on storing the images in the database other than Mysql, that would be helpful.

Thank you in advance.

Regards

VG

Vinay
  • 11
  • 2
  • 2
    Store the link instead of the image. Edit : [Storing Images in DB - Yea or Nay?](http://stackoverflow.com/q/3748/3361444) – Debflav Feb 10 '15 at 17:20
  • 2
    You can store images in the database, but it's not advisable and bad practice. – B001ᛦ Feb 10 '15 at 17:21
  • 2
    You should save the file to the volume and then store the filename in the db. – Daniel K Feb 10 '15 at 17:23
  • You can use cloud services like S3, flickr, or other image hosting if you don't want to worry about the disk usage or security considerations of storing the files on the disk. – PaulProgrammer Feb 10 '15 at 17:25

3 Answers3

1

Save yourself endless headaches, and store the file location in you database instead of a BLOB.

When you go to access it with PHP it is as simple as: query the DB and use the file location like so: <img src="{$dbResult['image']}" />

Dan
  • 10,614
  • 5
  • 24
  • 35
1

Storing images in database is bad practice. You shouldn't do like that. I invite you to read this article - Storing Images in DB - Yea or Nay?.

You can save images on your server and save their URI in database and then display them in similar way:

<img src="<?php echo $row['imageUrl']; ?>" alt="" />
Community
  • 1
  • 1
TN888
  • 7,659
  • 9
  • 48
  • 84
0

Adding the image URL would be a better option in my case. Hope it will make the website more Optimized.

Vinay
  • 11
  • 2