943,712 Members | Top Members by Rank

Ad:
  • ASP.NET Discussion Thread
  • Marked Solved
  • Views: 1508
  • ASP.NET RSS
Jun 8th, 2008
0

problem with uploading several images with the same name.

Expand Post »
I have a form where there is image, at the first time it displays the defualt image,when
the user uploads image, the new image appears. But when the user get out from this page and get in again and upload another image the same old image is still there. Its that when i upload image i give it id of employee. The same old image is there even if i render it in another page,although in the folder where the images are uploaded are changed with new image.

i would like to note that i am using windows vista, the desitination of upload is "E:\myporject\...", but the url of image is "../images/employees/123.jpg",
the image is being saved to the folder of development but the url of image is from the virtual path, even when i restart the computer and the visual studio, and the whole website its still there with the same old image.

plz help, how can i upload many images and give them the same name and only the last one is displayed in my application.
Thanks in advance.
Similar Threads
Reputation Points: 10
Solved Threads: 1
Light Poster
Jihad is offline Offline
32 posts
since Nov 2007
Jun 8th, 2008
1

Re: problem with uploading several images with the same name.

You need to force the browser to refresh it looks like. Im afraid the easiest method is to change its name. maybe you could add a time to the end of the file i.e. "filename_20080607.jpg" etc.
Reputation Points: 66
Solved Threads: 56
Posting Pro in Training
Fungus1487 is offline Offline
459 posts
since Apr 2007
Jun 8th, 2008
0

Re: problem with uploading several images with the same name.

I would like to mention that may it is not clear, but what I wanted to say that both I save to virtual path and read from virtual path. Here is the code that read image:

ASP.NET Syntax (Toggle Plain Text)
  1. Image1.ImageUrl = "~/images/employees/" + Request["empID"].ToString() + ".jpg";
Here is the code that upload image:

asp.net Syntax (Toggle Plain Text)
  1. if (fileUpload.HasFile)
  2. {
  3. // Get the name of the file
  4. string fileName = fileUpload.FileName;
  5. string ext = System.IO.Path.GetExtension(fileName.ToString());
  6. if (ext == ".jpg" || ext == ".jepg" || ext == ".JPG" || ext == ".JPEG")
  7. {
  8. fileName = Request["empID"].ToString() + ".jpg";
  9. // Upload the file on the server
  10. fileUpload.SaveAs(MapPath("~/images/employees/" + fileName));
  11. }
  12. }

Thanks for the try to name it with different name, using time but when i want to render the image, how can I know its name without saving it??!!
Last edited by peter_budo; Jun 10th, 2008 at 12:13 pm. Reason: Keep It Organized - please use [code] tags
Reputation Points: 10
Solved Threads: 1
Light Poster
Jihad is offline Offline
32 posts
since Nov 2007
Jun 8th, 2008
0

Re: problem with uploading several images with the same name.

I think I will stick to Fungus1487 suggestion, but I have to save the file name . Thanks Fungus1487, I give you credit
Reputation Points: 10
Solved Threads: 1
Light Poster
Jihad is offline Offline
32 posts
since Nov 2007

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in ASP.NET Forum Timeline: How to rewrite url
Next Thread in ASP.NET Forum Timeline: Validating registration details





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC