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

  • SEARCH
  • Home
  • 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 7803437
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T01:35:01+00:00 2026-06-02T01:35:01+00:00

Below is part of the code where it uploads a file (fileImage) into a

  • 0

Below is part of the code where it uploads a file (fileImage) into a folder (ImageFiles). But what I want to also do is INSERT the file location (The location the file is uploaded into) into the database using INSERT VALUES code. I want the file location to be inserted into the “ImageFile” field and for the “ImageId” I want it to display the string “IMG” and then include a number after the string. For Example:

In my database table if it reads like this:

ImageId     ImageFile

IMG1        ImageFiles/penguins.png
IMG2        ImageFiles/desert.png
IMG3        ImageFiles/jellyfish.jpg

Then if I upload the file from my computer ‘tulips.png’ into the ImageFiles folder, then in the database it should insert the values like this below:

ImageId    ImageFile

IMG4       ImageFiles/tulips.png

But how can this be coded? Below is my code at the moment which uploads the file successfully and contains only partial coding of the INSERT VALUES:

      move_uploaded_file($_FILES["fileImage"]["tmp_name"],
      "ImageFiles/" . $_FILES["fileImage"]["name"]);
      $result = 1;

      $imagesql = "INSERT INTO Image (ImageId, ImageFile) 
    VALUES ("");

mysql_query($imagesql);
  • 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-02T01:35:04+00:00Added an answer on June 2, 2026 at 1:35 am

    You should use an auto incremented id for identifying images instead of using strings for this.

    This would ease up the process for you as you would only have to insert a single fields and the autoi ncremented fields updates automatically.

    $imagesql = "INSERT INTO Image (ImageFile) VALUES ('ImageFiles/".mysql_real_escape_string($_FILES['fileImage']['name'])."')";
    

    ImageId should then be of type INT as PRIMARY KEY with AUTO INCREMENT instead. That’s also a good way to design your tables.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Below is part of my code to read data from a text file, strip
Below is the part code I currently use to write to a file, Try
Below, I inserted a code written by Ray Konopka (part of the Coderage presentation).
20120315021529.000[-8:PST] to get the first part I was able by using below C# code.
Thanks for the response, @ManselUK Fixed this part with finding values(below) But , when
The function below is part of the code for Google's Camera app. I didn't
The function below is part of the code for Google's Camera app. It is
This is a jQuery example. But i didn't get the part below: var replacement
what is the problem in the code part below? Any ideas? I m sending
All the code/commands below are part of a PHP script that processes images from

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.