大佬教程收集整理的这篇文章主要介绍了无法将文件上传到 html/python 脚本,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我有这个 HTML 代码调用这个 Python 脚本,它允许用户将@R_502_6764@到服务器,在这种情况下是我的本地磁盘,但是每当我按下上传按钮时,python 脚本没有被激活,我只会得到提示使用其他应用程序运行 python 脚本,或者简单地将 python 文件保存到我的下载文件夹中。任何想法将不胜感激。我也在尝试在 Ubuntu 上运行它
<HTML>
<body>
<form enctype = "multipart/form-data"
action = "save_file.py" method = "post">
<p>file: <input type = "file" name = "filename" /></p>
<p><input type = "submit" value = "Upload" /></p>
</form>
</body>
</HTML>
#!/usr/bin/python
import cgi,os
import cgitb; cgitb.enable()
form = cgi.FIEldStorage()
# Get filename here.
fileitem = form['filename']
# Test if the file was uploaded
if fileitem.filename:
# Strip leading path from file name to avoID
# directory traversal attacks
fn = os.path.basename(fileitem.filename.replace("\\","/" ))
open('/tmp/' + fn,'wb').write(fileitem.file.read())
message = 'The file "' + fn + '" was uploaded successfully'
else:
message = 'No file was uploaded'
print """\
Content-Type: text/HTML\n
<HTML>
<body>
<p>%s</p>
</body>
</HTML>
""" % (message,)
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)
以上是大佬教程为你收集整理的无法将文件上传到 html/python 脚本全部内容,希望文章能够帮你解决无法将文件上传到 html/python 脚本所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。