Click here to Skip to main content
16,004,778 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
with out asking any save dialog box my pdf save in a folder
i tried like this
C#
Response.ContentType = "application/pdf";
         string fname = "SampleInvoice.pdf";
         Response.AppendHeader("content-disposition", "attachment; filename=" + fname + "");
         string ServerPath = Server.MapPath("~/NewFolder4/");
         
          HttpContext.Current.Response.TransmitFile(path+fname);


but it not working
can any one help me ?
Posted

1 solution

You can't.
The client has full control over where downloaded items are stored (and it varies from browser to browser anyway depending on their configuration) - the server cannot influence that at all (except in circumstances which do not occur in 99.999% of conditions)

Think about it: you do not know what kind of device the client is: it could be a PC, Mac, Phone, Tablet, or internet enabled fridge. It may not even have a concept of folders!
 
Share this answer
 
Comments
Raajkumar.b 18-Jan-14 2:57am    
pdf file save in folder of server
OriginalGriff 18-Jan-14 3:02am    
Then why does your code send it to the client?
Raajkumar.b 18-Jan-14 4:10am    
you said it is not possible (client side)
is it possible to save file at server side
OriginalGriff 18-Jan-14 5:09am    
Not with that code: that downloads a file from the server to the client.
You need a client initiated upload: see the FileUpload control (MSDN will have an example)

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