Click here to Skip to main content
15,893,594 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi All,
I need to download a pdf file to a project folder on button click.However it's not working.It's downloading to system folder.Any help will be really appreciated.

What I have tried:

pdfDoc.Add(pdfTable);
               pdfDoc.Close();
               Response.ContentType = "Application/pdf"; ;
               string newfile = Name+"_"+DateTime.Now.ToString("dd-MMM-yyyy")+".pdf";
               Response.AppendHeader("Content-Disposition", "attachment; filename=" + newfile);

               Response.TransmitFile(Server.MapPath("~/produuct/Reports/" + newfile));

               Response.End();
Posted
Updated 27-Nov-17 0:27am

You can't control where a file is saved on the client, the user can save it anywhere they want or not save it at all.
 
Share this answer
 
Comments
Member 12926744 27-Nov-17 6:26am    
How can we save it to a specific folder in server .
F-ES Sitecore 27-Nov-17 6:36am    
You can't.
You can't specify a destination directory when transmitting a file for download with a web response.

The client (browser) receiving the file should open a save as dialog so that the user can choose where to store the file. The initial directory from that dialog is usually configurable in the browser (download directory).

If the request has not been send by a browser but some kind of application, it is up to that application where to store downloaded files.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900