Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8229819
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T16:55:31+00:00 2026-06-07T16:55:31+00:00

I am storing images name inside on MySQL database. Everytime I perform an upload,

  • 0

I am storing images name inside on MySQL database. Everytime I perform an upload, I have it return a link back with the image name attached which then I extract the image name and saved to the database. I have corrections to some critical flaws but I am still facing issues of having blank spaces/ duplicate names inserted into my database even though I have established checkpoints.

How can I avoid duplication/blank spaces of file names?

Is there a better approach in storing names in DB?

enter image description here

Location of image inside webserver:

http://www.example.com/imageupload/uploads/medium/50038dc14afb7.jpg

Link in the browser:

http://www.example.org/imageupload/index.php?i=50038dc14afb7.jpg

PHP

<?
    $images = retrieve_images();
    insert_images_into_database($images);

    function retrieve_images()
    {        
        $images = explode(',', $_POST['i']);
        return $images;
    }

    function insert_images_into_database($images)
    {
        if(!$images) //There were no images to return
            return false;        

        $db = dbConn::getConnection();

        foreach($images as $image)
        {
            $sql = "INSERT INTO `urlImage` (`image_name`) VALUES ( ? )";
            $prepared = $db->prepare($sql);
            $prepared->execute(array($image));
        }
    }

?>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T16:55:33+00:00Added an answer on June 7, 2026 at 4:55 pm

    First, the blank name issue can perharps be fixed by checking $_POST['i']:

    if (!isset($_POST['i'])) {
        echo "No image to upload!";
        die();
    }
    

    Have you tried redirecting after uploading the image?

    // When image is uploaded
    header("Location: http://example.org/imageupload/index.php");
    die();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The best way to store images into MySQL is by storing the image location
I have a database and I'm storing images in it along with a person's
Suppose I have string Name and Image Photo as properties of a class in
I am storing a few images in MYSQL for security reasons. When I download
I have successfully managed to bind images stored in Isolated Storage to Image elements
Hi i have been looking for a solution to display images in image control
my model store image described with file name (as String) and data (as byte
Possible Duplicate: Storing Images in DB - Yea or Nay? For ages I've been
I just switched from storing my images uploaded via Carrierwave locally to using Amazon
I just started storing user uploaded images on Amazon's S3. It's pretty nice because

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.