Temporary ID

ANB 181 Reputation points
2021-11-12T16:12:36.303+00:00

I have an application which contains a product form and inside of it, a section for image uploads.
When a person uploads a file, I make a POST via AJAX and the file should be saved in /myServer/productID/fileName

However I will just have the productID later when I submit the product form.
How can I do that ?

Thank you

Developer technologies | C#
{count} votes

2 answers

Sort by: Most helpful
  1. Bruce (SqlWork.com) 78,006 Reputation points Volunteer Moderator
    2021-11-12T16:19:45.72+00:00

    you can use a guid for a temp id and return to the Ajax caller (encrypted if security is important). then rename the file when you have the correct. I'd add a static prefix, so you can identity images that were uploaded, but no form post was received.

    0 comments No comments

  2. ANB 181 Reputation points
    2021-11-12T17:37:33.517+00:00

    This way I could rename the file on the database later when the product form is submitted.
    However I still need a task to move the file from the temporary folder to the right one right ?

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.