我想使用 Microsoft IIS 设置直接下载链接。我们已经有一个使用 IP 地址的网页,该地址指向我们服务器上的 /web 文件夹,但我想在我的服务器上创建一个单独的位置,我可以在其中放置可下载的文件,以便客户端只需键入链接即可获取下载:http://IPADDR/download/filename.zip。有关于如何执行此操作的任何资源吗?
现在,输入 http://IPADDR 将显示我们的简单网页,其中包含启动应用程序的链接,这又通过 IIS 绑定到我们服务器上的 /web 文件夹。
FTP 端口通常在我们客户端的网络上被阻止,因此我们必须坚持使用 HTTP。这将完全是程序化的,因此页面上不需要有按钮或链接。我将使用 java 和 GET 命令从链接中提取文件。我只是想让网络服务器使这些文件可供下载。
仅供参考,我对这个服务器的东西比较陌生,所以越简单越好!谢谢。
据我所知,有两种方法可以满足您的需求。
第一个是使用 Asp.net 应用程序。您需要为下载的文件编写代码。例如,当用户点击某个按钮时,会触发该按钮对应的逻辑方法,响应给客户端的是代码中指定的文件。
var fileNameToShow = "xxx.zip";
var fileNameAndPath = "The physical path of the file on the server"
FileInfo file = new FileInfo(fileNameAndPath);
file.Refresh();
if (file.Exists)
{
// Send the file to the browser
Response.Clear();
Response.AddHeader("Content-Disposition",
"attachment; filename= " + fileNameToShow + "; size=" + file.Length.ToString());
Response.TransmitFile(fileNameAndPath);
Response.Flush();
Response.End();
}
else
{
throw new Exception("File does not exist!");
}
The second is to use the FTP function of IIS. You need to create a site and add FTP publishing to the site. When you visit the site through ftp://domian, you can see all the files in the physical directory of the site on the server, and you can download any file by clicking on it.(It also can download through link,such as ftp://domain/filename.zip)
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)