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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T23:41:53+00:00 2026-06-09T23:41:53+00:00

So I’ve made a gallery web page that supports uploading several images in one

  • 0

So I’ve made a gallery web page that supports uploading several images in one go. The problem is that I’ve made it so that any image that gets uploaded gets a file name like [username]_[unix timestamp].jpg

When viewing all uploaded images, the images are sorted by date. Initially this was a problem when uploading a lot of images because they all got very similar datetime stamps. Down to the same second. I was using get_next_by_date() and get_previous_by_date() to browse the images, and this did not work well when many images was stored down to the same second.

Another problem was that since the image processing was done with a speed of typically three images per second made three and three images get the same unix timestamp. This caused the same image that was the first to be processed in a second be represented three times on the site instead of the other images that was processed later that same second. (Operating System gave the files a different name when it found that the name was already taken, but the database still stored the original timestamp to filenames).

So far I’ve “fixed” the problem by popping a time.sleep(1) after each image is processed to guarantee a new second being started for each image, but this just makes me feel bad. 60 images to be uploaded is then guaranteed to take 60 seconds, while it shouldn’t have to take more than maybe 10-20 seconds.

Can anyone think of a solution to this? How can I make sure that images that are sorted on date can get the correct sequence when viewing images, and that the unix timestamp gets unique for all images?

  • 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-09T23:41:54+00:00Added an answer on June 9, 2026 at 11:41 pm

    You can create filename from timestamp using millisecond as well.

    Using strftime with millisecond to create string for filename:

    >>>import datetime from datetime
    >>>date1=datetime.utcnow()
    >>>date1.strftime("%Y_%m_%d_%H_%M_%S_%f")
    '2012_08_21_05_55_25_302249'
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

That's pretty much it. I'm using Nokogiri to scrape a web page what has
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I would like my Web page http://www.gmarks.org/math_in_e-mail.txt on my Apache 2.2.14 server to display
I'm making a simple page using Google Maps API 3. My first. One marker
link Im having trouble converting the html entites into html characters, (&# 8217;) i
Basically, what I'm trying to create is a page of div tags, each has
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace
I am reading a book about Javascript and jQuery and using one of the
I have a French site that I want to parse, but am running into

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.