Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/google-sheets/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 输入[type=file]返回空值_Python_Upload_Web.py - Fatal编程技术网

Python 输入[type=file]返回空值

Python 输入[type=file]返回空值,python,upload,web.py,Python,Upload,Web.py,我有一个脚本,可以根据webpy cookbook创建一个带有表单的弹出窗口: jQuery('#logo').click(function(){ var content = ('<h1>Upload logo</h1>' + '<form method="POST" enctype="multipart/form-data" action="/upload">' + '<input type="file" id=

我有一个脚本,可以根据webpy cookbook创建一个带有表单的弹出窗口:

jQuery('#logo').click(function(){
    var content = ('<h1>Upload logo</h1>' +
        '<form method="POST" enctype="multipart/form-data" action="/upload">' +
        '<input type="file" id="myfile" accept="image/jpeg,image/png,image/gif" />' +
        '<button id="upload" type="submit">Загрузить</button></form>'
        );
    popup(content);
});
但是当我试图上传文件时,我总是得到空的存储对象。

元素没有name属性,该属性将指示表单提交中的文件名。名称是必需的,因为您可以在一个表单中有多个输入字段,包括
file
字段。添加
name=
可以解决您的问题:

'<input type="file" name="myfile" id="myfile" accept="image/jpeg,image/png,image/gif" />'
//                  ^^^^^^^^^^^^^
“”
//                  ^^^^^^^^^^^^^
元素没有name属性,该属性将指示表单提交中的文件名。名称是必需的,因为您可以在一个表单中有多个输入字段,包括
file
字段。添加
name=
可以解决您的问题:

'<input type="file" name="myfile" id="myfile" accept="image/jpeg,image/png,image/gif" />'
//                  ^^^^^^^^^^^^^
“”
//                  ^^^^^^^^^^^^^