views:

41

answers:

1

Is it possible to rename file when trying to download it? For example, I would like to store files to folders using their id's but when user downloads file I'd like to return the original filename.

+2  A: 

just change name of file over here

Response.AppendHeader("Content-Disposition","attachment; filename=LeftCorner.jpg");

for example

 string filename = "orignal file name.ext";
 Response.AppendHeader("Content-Disposition","attachment; filename="+ filename  +"");

Downloading a File with a Save As Dialog in ASP.NET

Pranay Rana
How is download suppose to take place? I'm not following you...
ile
check the pasted link in answer
Pranay Rana
does this work with all filetypes (.zip, rar, pdf, etc)?
ile
@ile: That doesn't matter. You could use: Response.BinaryWrite(fileContent); aferwards.You must call Response.AppendHeader before you write anything Response or else it won't work. And you should also set the mime-type first: Response.ContentType="text/html";
SchlaWiener
Ok, thanks, I'll give it a try. Btw, it doesn't matter if the file is stored in DB or in the file system? (my case is file system)
ile
Yes, it works nice, this is just what I needed. Thanks :)
ile