Images Downloading from asp.net website

Please support our ASP.NET advertiser: Intel Parallel Studio Home
Thread Solved

Join Date: Jul 2008
Posts: 2
Reputation: Mythili.D is an unknown quantity at this point 
Solved Threads: 0
Mythili.D Mythili.D is offline Offline
Newbie Poster

Images Downloading from asp.net website

 
0
  #1
Jul 16th, 2008
Hello,
I have a website which allows the user to download the images from it. I used the following code. It download for most of the images but for some it tries to download as a file without extension. So can you please suggest what might be causing this.
thanks
Mythili
  1. // Output standard image
  2.  
  3. DataRow romImage = DAImage.GetImageByID(imageID);
  4. System.Drawing.Image image = GetImage(WebConfigurationManager.AppSettings["ImageLibraryPath"] + romImage["RelPath"]);
  5.  
  6. Response.Clear();
  7. string extension = romImage["RelPath"].ToString().Substring(romImage["RelPath"].ToString().LastIndexOf(".") + 1);
  8.  
  9.  
  10. Response.AddHeader("Content-Disposition", "attachment; filename=\"" + romImage["Description"].ToString() + "." + extension + "\"");
  11. Response.ContentType = "image/" + extension;
  12.  
  13. System.Drawing.Imaging.ImageFormat imgFormat = System.Drawing.Imaging.ImageFormat.Jpeg ;
  14.  
  15. image.Save(Response.OutputStream, System.Drawing.Imaging.ImageFormat.Jpeg);
Last edited by Tekmaven; Jul 16th, 2008 at 3:11 pm. Reason: Code tags
Reply With Quote Quick reply to this message  
Join Date: Apr 2007
Posts: 370
Reputation: greeny_1984 is an unknown quantity at this point 
Solved Threads: 29
greeny_1984's Avatar
greeny_1984 greeny_1984 is offline Offline
Posting Whiz

Re: Images Downloading from asp.net website

 
0
  #2
Jul 17th, 2008
hi,
y dont u use System.IO.Path.GetExtension
there u can get the extension.
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 2
Reputation: Mythili.D is an unknown quantity at this point 
Solved Threads: 0
Mythili.D Mythili.D is offline Offline
Newbie Poster

Re: Images Downloading from asp.net website

 
0
  #3
Jul 17th, 2008
Thanks for your response. I was looking for this over a day now. The good news is I found the solution. There was no problem in the code. It is problem with how the file is uploaded. It is the description or the filename by which this file is downloaded. If the file name has / because it is a escape sequence it is not downloaded properly. Hence it appeared as if it forgot the extension suddenly in the middle of downloading the file itself.
thanks
Mythili
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC