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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T05:03:00+00:00 2026-06-09T05:03:00+00:00

in my project i store images(uploaded by user) in a folder, for each respective

  • 0

in my project i store images(uploaded by user) in a folder, for each respective product.

For example to add a product a form is displayed to user. User fills details about product and selects some images from his computer(5 or more pictures). When submitted i will store product details in a table called Products. For images uploaded, i create a folder like this: http://mysite.com/uploads/123/ here 123 is product id of product that is newly added. And all images are saved inside it.

Questions:

  • how to keep track of images uploaded(or filenames of it) for later displaying? that is, when a new product is added, my script will create a fancy uri text. Eg: http://mysite.com/this-is-my-new-product. So if user visits this link, it should show all images belonging to that product. For this, I have to keep a separate table with product ids and the filenames ? And query this table and echo filenames from it? Or is it good to scan the folder(example: http://mysite.com/uploads/123/*.jpg) and echo images one by one, ie. without using a separate table ?

  • is it ok if use the fancy uri for the filenames of images? Example: /uploads/123/this-is-my-new-product1.jpg, /uploads/123/this-is-my-new-product2.jpg, /uploads/123/this-is-my-new-product3.jpg, etc. ? So, users will see path of first image as http://mysite.com/uploads/123/this-is-my-new-product1.jpg. This is physical address. Will it help in SEO ? Or it is bad practice ? If this is good, then to list all images i should use scanddir() ?

Please guide me through correct path. Thanku

  • 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-09T05:03:01+00:00Added an answer on June 9, 2026 at 5:03 am

    As you say, you either need some link between the data and the images, or be prepared to scan the folder and just output what you find. The latter is more computationally expensive and not altogether graceful as an approach.

    A compromise might be to rename the images, as they’re uploaded, 1.jpg, 2.jpg etc and then simply log in the DB the number of images uploaded. Example:

    if ($res = $db->query("query to get product row here")) {
        $row = $res->fetch_assoc();
        if (isset($row['num_imgs'])) {
            for($i=0; $i<$row['num_imgs']; $i++) {
                $img_path = $product_folder_uri."/".($i+1).".jpg";
                if (file_exists($img_path))
                    echo "<img src='".$img_path."' />";
            }
        }
    }
    

    If you were unwilling to rename the images from their uploaded names, you would need to log their names in the DB, presumably in their own table and via a foreign key to the product table.

    A final option would be to store the images as blobs in the database, but I’m no DB expert so I don’t know how widespread or advisable this is.

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

Sidebar

Related Questions

I'm writing a project in Django that has user uploaded images related to products,
the images should be store in a directory(image) under the project
I have a folder name: 'create_assets', where I store my source files of images
Every new project that the client registers the system creates a folder to store
I have a WPF project. If I store image in {ProjectRoot}\Images\image.png, and compile it
I have 4 projects in same solution. In one project the images get uploaded
my goal is to store information about projects within Jackrabbit. Each project can consist
I am working on a project that must store very large datasets and associated
I'm working on a project where I store an id in a table, which
My personal rails project uses a few API's for which I store the API

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.