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 7821817
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T07:45:40+00:00 2026-06-02T07:45:40+00:00

before uploading an image, system has to know uploading path. Image path is generated

  • 0

before uploading an image, system has to know uploading path.
Image path is generated by image ID.
for example: image 123456 has this path images/123/456
Of course, image ID will be = the last inserted image ID + 1
How to get the ID of the last uploaded image (data is stored in database)

I could do
select max(image_id) from images

or
select image_id FROM images order by image_id desc limit 1

but them seems to be a lot of work every time some user wants to upload an image.

Is there some simpler solution to get last ID

  • 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-02T07:45:42+00:00Added an answer on June 2, 2026 at 7:45 am

    You need to do it in a few steps.

    1. user uploads the image
    2. you insert a skeleton record in the database, so you can get this new record’s ID
    3. process/move the uploaded file, using this new id
    4. update the skeleton record to ‘activate’ it

    You cannot do this BEFORE the upload, because PHP does not start executing until AFTER the upload has been completed.

    For maximum safety, you do the database operations in a transaction. If there’s any problems with the upload (wrong file type, upload failed, can’t process file, etc…) you simply roll back the transaction and everything’s undone.

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

Sidebar

Related Questions

So, if this question has been asked before, I'm sorry. I'm not exactly sure
I have used the following code before uploading an image into mysql database Before
I want to resize the resolution of an image before uploading it to local
I'm uploading image file to storage server. Before uploading I should compose filename, which
How can I check for height and width before uploading image, using PHP. Must
Im working on image preview before uploading with JQuery, it's working in chrome, and
I am uploading an image to a server and before that happens, I would
in my application i am uploading the image into database. before it is store
I am using canvas to manipulate images, crop, resize and optimise before uploading them.
I'm implementing a user-based image uploading tool for my website. The system should allow

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.