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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T16:52:19+00:00 2026-05-30T16:52:19+00:00

Im writing my first online shop in PHP. Now working on add product form

  • 0

Im writing my first online shop in PHP. Now working on “add product” form and im not sure know how to store images.

I think i should:

  1. check is this image or not
  2. resize image to “standard” dimensions used in my shop and generate thumbnail
  3. generate unique filename and store image in “images” directory
  4. save image with unique filename and insert row into my Images table

I created table with columns like this:

  • Id
  • Location – url of image – “/0953026326323436324.jpg” for example
  • OriginalFilename – original name of file that user was uploading – “myproduct1.jpg” for example

Questions:

  1. Is there any better way to do this?
  2. Shall i use Id from Images table as unique filename, or shall i stay with generating unique name (by using PHP function)?
  3. Shall i generate md5 hash and store it in Images table to avoid/handle duplicates?

Edit 2012-03-03:
By duplicates I mean files with identical content (but maybe diffrent name).

Im not using any framework, that will be simple and lightweight online-shop.

  • 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-05-30T16:52:20+00:00Added an answer on May 30, 2026 at 4:52 pm

    It really depends on what your application does with those images. These are some of the things I learnt by experience…

    How many images?
    If we are talking about thousands of images, keep in mind that a folder with that amount of files is probably not accesible via FTP. You can classify them and put them in different subfolders if you need access to them.
    Classification can be done by a number of things… from size to odd/even ID numbers. It all depends on how much you need to split them up.

    Are they private images? Should they be publicly accesed? If you use just the ID as unique identifier, it’s pretty easy to guess and find other images, since they are most likely auto-incremental. You can generate a more secure name in those cases just throwing user IDs, timestamps, random numbers, a hash, or whatever combination…

    Hashing the names? You don’t get any extra security off of this. If you are already using a combination of things of the names, hashing it is just an extra thing to do. Say you are using [image_id]_[timestamp] for the names, if you hash it, you lose that information. You do have it in your database, but it’s also good having it in the file names. If for some reason, you need to delete certain files it would be easier if you could recognize them. And, going back to the amount of images you may have… there could be collitions in the MD5. Meaning 2 files would get the same name.. (It’s really rare, but it could happen)


    Since it’s a store, I’m guessing you don’t need the extra security on the image names, but you might need the extra classification.

    Btw, according to your step by step, you can’t use the ID of the image for the filename because you insert the row into the table AFTER saving the image.

    If you need more details, do leave a comment.

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

Sidebar

Related Questions

Writing my first C# application...never touched the language before and not much of a
When I first started writing CSS, I was writing it in an expanded form
Background I am writing a simple online judge (a code grading system) using PHP
Let's say I'm writing a eBook reader for Windows Phone 7. Now the first
I'm writing my first Rails app and I'm confused by a method call that
I'm writing my first batch file, and as I've never used Windows Command Line
i'm writing my first MATLAB O-O application and i'm confused about the implementation of
I am writing my first dual app and cannot figure out how to give
So i am writing my first Java application using MVP pattern. One of MVPs
I'm writing my first extbase extension for TYPO3 with nested models at the moment.

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.