User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the ASP.NET section within the Web Development category of DaniWeb, a massive community of 423,432 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 4,701 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our ASP.NET advertiser: Lunarpages ASP Web Hosting
Views: 417 | Replies: 3 | Solved
Reply
Join Date: Nov 2007
Posts: 26
Reputation: Jihad is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 0
Jihad Jihad is offline Offline
Light Poster

problem with uploading several images with the same name.

  #1  
Jun 8th, 2008
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.
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Apr 2007
Location: Birmingham
Posts: 378
Reputation: Fungus1487 is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 37
Fungus1487's Avatar
Fungus1487 Fungus1487 is offline Offline
Posting Whiz

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

  #2  
Jun 8th, 2008
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.
When Autumn Falls [ http://www.whenautumnfalls.co.uk ] &&
Designdotworks [ http://www.designdotworks.co.uk ] Web / Graphic / Software Design
Reply With Quote  
Join Date: Nov 2007
Posts: 26
Reputation: Jihad is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 0
Jihad Jihad is offline Offline
Light Poster

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

  #3  
Jun 8th, 2008
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:

Image1.ImageUrl = "~/images/employees/" + Request["empID"].ToString() + ".jpg";
Here is the code that upload image:

  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 11:13 am. Reason: Keep It Organized - please use [code] tags
Reply With Quote  
Join Date: Nov 2007
Posts: 26
Reputation: Jihad is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 0
Jihad Jihad is offline Offline
Light Poster

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

  #4  
Jun 8th, 2008
I think I will stick to Fungus1487 suggestion, but I have to save the file name . Thanks Fungus1487, I give you credit
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb ASP.NET Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the ASP.NET Forum

All times are GMT -4. The time now is 2:09 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC