简体   繁体   English

在Mysql Local服务器中存储大尺寸(10MB)图像

[英]Storing large size (10MB) images in Mysql Local server

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. 因此,当我尝试使用LONGBLOB将这些图像存储在Mysql表中时,它仍然引发有关大小的错误。 Once the images are stored in the database, I want to fetch them in the website using PHP. 一旦图像存储在数据库中,我想使用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. 谁能告诉我该怎么做,并且除了MySQL以外,如果在数据库中存储图像还有其他选择,那会有所帮助。

Thank you in advance. 先感谢您。

Regards 问候

VG VG

Save yourself endless headaches, and store the file location in you database instead of a BLOB. 避免无休止的头痛,并将文件位置存储在数据库中而不是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']}" /> 当您使用PHP访问它时,它很简单:查询数据库并使用文件位置,如下所示: <img src="{$dbResult['image']}" />

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? 我邀请您阅读这篇文章- 在DB中存储图像-是或否? .

You can save images on your server and save their URI in database and then display them in similar way: 您可以将图像保存在服务器上并将其URI保存在数据库中,然后以类似的方式显示它们:

<img src="<?php echo $row['imageUrl']; ?>" alt="" />

Adding the image URL would be a better option in my case. 在我的情况下,添加图像URL是更好的选择。 Hope it will make the website more Optimized. 希望它将使网站更加优化。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM