Pdf文件未下载到指定的文件夹 [英] Pdf file not downloading to a specified folder

查看:107
本文介绍了Pdf文件未下载到指定的文件夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我需要在点击按钮时将pdf文件下载到项目文件夹。但是它不能正常工作。它正在下载到系统文件夹。任何帮助都将非常感谢。



我尝试过:



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();

推荐答案

您无法控制客户端上文件的保存位置,用户可以将其保存在任何他们想要的位置或者根本不保存。
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.


在传输文件以便通过Web响应下载时,无法指定目标目录。



接收文件的客户端(浏览器)应打开另存为对话框,以便用户可以选择存储文件的位置。该对话框中的初始目录通常可在浏览器中配置(下载目录)。



如果请求尚未由浏览器发送,而是某种应用程序,则取决于该应用程序存储下载文件的位置。
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.


这篇关于Pdf文件未下载到指定的文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆