skip to Main Content

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:xamppphpMyAdminlibrariesclassesError.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 LARGEBLOBs?

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!

2

Answers


  1. Chosen as BEST ANSWER

    So I have looked into using VARCHAR on my phpMyAdmin for my images and inputted there, the location of my image (i.e - 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.


  2. 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
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search