简体   繁体   中英

Is there any other way to store image in phpMyAdmin other than the BLOB type?

I am using phpMyAdmin and I have been trying to store input images directly on phpMyAdmin as a LARGEBLOB type. However, it doesn't upload properly and I have encountered errors such as

"Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 2182024 bytes) in D:\\xampp\\phpMyAdmin\\libraries\\classes\\Error.php on line 373" or "Server is away."

I was pretty sure that I kept the images within the alloted limit (2046KiB) that a LARGEBLOB could allow (I am trying to upload an image of 1MB) but somehow I couldn't get to upload it somehow. So is there any other way to insert an image into phpmyadmin? or a remedy so I could keep using LARGEBLOB s?

I have seen people replying to others' posts about converting images to base64 and uploading them as strings but I am not sure how that works or how to do it.

Please shine some light on this matter. Thanks!

I don't know why you are uploading blob image data to DB, the good and efficient method:

  1. Upload the image to the folder
  2. Keep the uploaded path in the data column

So I have looked into using VARCHAR on my phpMyAdmin for my images and inputted there, the location of my image (ie - images/car.jpg). And using this code -

<?php
require "dbconfig.php";
$query =  $query = "SELECT * FROM images";
$result = mysqli_query($link, $query);
while ($row = mysqli_fetch_array($result)){
$image = $row['image'];
}
?>
<img class="img-fluid" src="<?php echo $picture; ?>" alt="">

I was able to find loophole around using BLOB for images. This, however does not store the image on the database but the file location. Therefore you should not lose the folder.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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