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 +"");
Pranay Rana
2010-06-21 12:31:35
How is download suppose to take place? I'm not following you...
ile
2010-06-21 12:35:42
check the pasted link in answer
Pranay Rana
2010-06-21 12:37:12
does this work with all filetypes (.zip, rar, pdf, etc)?
ile
2010-06-21 12:40:50
@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
2010-06-21 12:41:07
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
2010-06-21 12:50:23
Yes, it works nice, this is just what I needed. Thanks :)
ile
2010-06-21 13:00:08