我通过这种方式在表单内提交文件(带有提交按钮、表单标签等):
<fieldset>
<input type="file" name="file" />
</fieldset>
我正在尝试以这种方式将其与 PHP 一起使用:
$file = $orgname."/".basename($_FILES['file']['name']);
move_uploaded_file($_FILES['file']['tmp_name'], $file);
我收到了这些错误:
Notice: Undefined index: file in C:\wamp\www\generic\addorg.php on line 45
Notice: Undefined index: file in C:\wamp\www\generic\addorg.php on line 46
这可能是什么原因造成的?我调查过的所有内容都表明它应该有效。
最佳答案
需要设置表单enctype=multipart/form-data
关于php - $_FILES 不工作?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8246569/