【发布时间】:2014-04-07 18:18:25
【问题描述】:
当我上传文件时,结果总是空的。 代码来自here。
index.html 文件:
<html>
<body>
<form action="upload_file.php" method="post"
enctype="multipart/form-data">
<label for="file">Filename:</label>
<input type="file" name="file" id="file"><br>
<input type="submit" name="submit" value="Submit">
</form>
</body>
</html>
upload_file.php:
<?php
echo "Upload: " . $_FILES['file']['name'] . "<br>";
?>
结果是:
上传:
我配置了我的 php.ini,也启用了 file_upload、内存 5000M 和 tmp 位置。
我不知道这很重要,但我使用的是 Ubuntu。
phpinfo的结果和我配置的一样
怎么了?谢谢!
print_r 是显示数组()
回显 $_FILES['userfile']['error'];
HP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php5/20090626+lfs/msql.so' - /usr/lib/php5/20090626+lfs/msql.so: cannot open shared object file: No such file or directory in Unknown on line 0
[Wed Mar 05 17:48:16 2014] [notice] Apache/2.2.22 (Ubuntu) PHP/5.3.10-1ubuntu3.10 with Suhosin-Patch configured -- resuming normal operations
[Wed Mar 05 17:50:05 2014] [error] [client 127.0.0.1] File does not exist: /var/www/favicon.ico
[Wed Mar 05 17:50:05 2014] [error] [client 127.0.0.1] File does not exist: /var/www/404.html
[Wed Mar 05 17:55:32 2014] [error] [client 127.0.0.1] PHP Notice: Undefined index: file in /var/www/uploadart.php on line 2, referer: http://localhost/index.php
在我原来的文件错误日志是空的。
【问题讨论】:
-
您是否尝试在更改 php.ini 设置后重新启动 Apache?
-
大约 3 次。我试过了。
-
向我们展示
print_r($_FILES);的输出,就像@OneOfOne 建议的那样。 -
print_r 没有显示任何内容,只是 Array()
-
如果这是您的全部代码,那么您缺少
move_uploaded_file()
标签: php html file-upload is-empty