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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T15:41:51+00:00 2026-05-20T15:41:51+00:00

This is more of a conceptual question and not about the underlying programming technique.

  • 0

This is more of a conceptual question and not about the underlying programming technique.

When I am in the process of creating a new record (say an Add Record screen), the record ID isn’t available to me yet. The same screen has an option of uploading a picture too, using SWFUpload – which means the picture gets uploaded immediately.

Since the record id isn’t available yet, there’s no way to associate this particular picture with a record in the DB till I’ve hit the Save button.

Now suppose, after uploading the picture I navigate away from the Add record screen leaving an orphaned picture file on the server.

I can come back to the Add record screen and keep doing this on and on… and eat up a sizable chunk of the server space with unlinked / unused images.

How would you tackle this issue? What flow of logic should be enforced here?

One option (which I’m experimenting with right now), is to store the uploaded images in a tmp folder and moving them out and placing them in another proper folder once the record has been created (with a link the the picture in it’s final resting place). And then, run nightly cron jobs to clear off the leftovers from the tmp folder.

Any other brighter and elegant approaches to this?

Thanks,
m^e

  • 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-20T15:41:52+00:00Added an answer on May 20, 2026 at 3:41 pm

    Kinda old question so you probably figured it out but this is how I go around it:

    1. Create a field in your db called ImgGuid with default value of 0 (varchar) to identify the image. I normally just use a Guid with or without image extension. Paths can be configured elsewhere.
    2. Create a hiddenfield in your upload page called hfImgGuid (or whatever) and load the ImgGuid value from the database, if there’s no record the value should be 0
    3. Now in your upload handler check if
      the value is 0, if so create a new
      Guid for this image and return it to
      your swfupload and set your hfImgGuid with this value. Also store the Guid in the user Session.
    4. When the user presses ‘Save’ the hfImgGuid value will get saved in the ‘ImgGuid’ field and so your image is connected to a record. When the user want to change its photo later u can just choose to overwrite the current image (or create a new Guid and delete the old one but for this example its easier)
    5. Only problem we got is that when a user creates on ‘New record’ and he uploads a pic and then decides to leave the page you find yourself with an orphant image. So here comes the user session into place. When the user saves the page you can remove the image from the session, if the user doesnt save it and the session ends you can read the values and delete the orphant images.

    I hope you get the idea, it can get very complex if you want to do it right and there are many ways to do it, but an ajax-style upload looks nice indeed and professional pages are hardly to be found without it.

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

Sidebar

Related Questions

So this question is not so much technical but more sort of conceptual. I
This is more of a business-oriented programming question that I can't seem to figure
EDIT: This question is more about language engineering than C++ itself. I used C++
this was more a conceptual question, but I was wondering what the best C#
This is more like a conceptual question. When to use Model Binding (in ASP.NET
This is more of an academic inquiry than a practical question. Are there any
This is more of an generic XML Schema question, but if and how do
This is more an observation than a real question: MS-Access (and VBA in general)
This is more of a syntax question I'm trying to write a store procedure
Ok this is more of a computer science question, than a question based on

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.