简体   繁体   English

下载文件链接产生404页面

[英]download file link produces 404 page

I am trying to create a link that allows a user to download a zip file that's been generated earlier in the python script. 我正在尝试创建一个链接,允许用户下载之前在python脚本中生成的zip文件。 The script then writes an HTML link to a web page. 然后,该脚本将HTML链接写入网页。 The user should be able to click the link and download their zip file. 用户应该能够单击该链接并下载其zip文件。

import os,sys
downloadZip = ("http://<server>/folder/structure/here/" + zipFileName + ".zip")
print """<h3><a href="{}" download>Download zip file</a></h3>""".format(downloadZip)

The result is a link that when clicked opens a 404 page. 结果是单击时打开404页面的链接。 I've noticed that on that page, it displays 我注意到在那个页面上显示了它

Physical Path      C:\inetpub\wwwroot\inputted\path\here\file.zip

I am testing this on the same server the processing is occurring on. 我正在进行处理的同一台服务器上测试它。 I wouldn't think that should make a difference, but here I am. 我不认为这应该有所作为,但我在这里。 The end result should be a zip file downloaded to the user's pc. 最终结果应该是下载到用户电脑的zip文件。

Not sure if this would be helpful or not but I have noticed that some 'server package apps' disallow the execution/download of certain filetypes. 不确定这是否有用但我注意到某些“服务器软件包应用程序”不允许执行/下载某些文件类型。 I had a similar thing happen years ago. 几年前我发生了类似的事情。

To test if this is the case, create a new folder in your web directory and add an index.html page with some random writing (to identify that you have the correct page). 要测试是否是这种情况,请在您的Web目录中创建一个新文件夹,并添加一个随机写入的index.html页面(以确定您拥有正确的页面)。 Quickly try to access this page. 快速尝试访问此页面。

Next create a .zip file, put it in the same folder as the index.html file you just created, and add a Download link on the index.html page. 接下来创建一个.zip文件,将其放在与刚刚创建的index.html文件相同的文件夹中,并在index.html页面上添加一个下载链接。

Now revisit the page, and try to download the file you created. 现在重新访问该页面,并尝试下载您创建的文件。 If it works then there is a problem elsewhere, if it doesn't then whatever server package application you are using probably set Apache to block .zip files by default. 如果它工作,那么在其他地方有一个问题,如果它没有,那么你正在使用的任何服务器包应用程序可能默认设置Apache来阻止.zip文件。 Hope this helps buddy :) 希望这有助于哥们:)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM