[英]No file upload on php built-in web server
I have the following html form: 我有以下HTML表单:
<form method="post" enctype="multipart/form-data"> File: <input type="file" name="file"><br> Name: <input type="text" name="file_name"><br> <input type="submit" name="action" value="Upload"> </form>
But the file never gets uploaded. 但是文件永远不会上传。 The text field is just there as debug code.
文本字段就在那里作为调试代码。
The following php code: 以下php代码:
<?php
echo "<pre>";
print_r($_POST);
echo "</pre>";
?>
Gives the following output when I fill all the forms values: 当我填写所有表单值时,将提供以下输出:
Array (
数组(
[file_name] => abc
[文件名] => abc
[action] => Upload )
[操作] =>上传)
And I'm running a php server as follows: 而且我正在运行一个php服务器,如下所示:
php -nS localhost:8000 -t .
php -nS localhost:8000 -t。
Am I doing anything wrong here? 我在这里做错什么吗? It's all running locally and the file I'm uploading is less than 10 bytes long.
它们都在本地运行,我上传的文件不到10个字节。
您将在以下变量中找到有关上载文件的数据: $_FILES["file"]
而不是在$_POST
变量中。
First, ensure that PHP is configured to allow file uploads. 首先,确保将PHP配置为允许文件上传。
In your "php.ini" file, search for the file_uploads directive, and set it to On: 在“ php.ini”文件中,搜索file_uploads指令,并将其设置为On:
file_uploads = On file_uploads =开
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.