我似乎根本无法让php处理上传的文件。我当前的代码如下所示:
<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
?>
<html>
<body>
<form action="" method="POST" enctype="multipart/form-data">
<input type="file" name="image">
<input type="submit">
</form>
<p>Sent file: <?php echo $_FILES['image']['name']; ?></p><br>
<p>File size: <?php echo $_FILES['image']['size']; ?></p><br>
<p>File type: <?php echo $_FILES['image']['type']; ?></p><br>
<?php print_r($_FILES); ?>
</body>
</html>我的php.ini文件:
;;;;;;;;;;;;;;;;
; File Uploads ;
;;;;;;;;;;;;;;;;
; Whether to allow HTTP file uploads.
; http://php.net/file-uploads
file_uploads = On
; Temporary directory for HTTP uploaded files (will use system
default if not
; specified).
; http://php.net/upload-tmp-dir
;upload_tmp_dir =
; Maximum allowed size for uploaded files.
; http://php.net/upload-max-filesize
upload_max_filesize = 10000M
; Maximum number of files that can be uploaded via a single request
max_file_uploads = 20在上传我得到的任何东西时:
Sent file:
Notice: Undefined index: image in
/var/www/upload.php on line 13
File size:
Notice: Undefined index: image in
/var/www/upload.php on line 14
File type:
Notice: Undefined index: image in
/var/www/upload.php on line 15
Array()这很可能是显而易见的,但对于我的生活来说,我找不到我做错了什么。
发布于 2017-11-05 13:29:47
您需要指定一个操作(php文件)来处理表单提交,更具体地说,就是保存该文件。
See examples and documentation at http://php.net/manual/en/features.file-upload.post-method.php
此外,请确保检查web服务器上所需上载目录的权限。在LAMP环境中,apache用户和www-data组应该拥有该文件夹并对其具有写权限。
https://stackoverflow.com/questions/47206222
复制相似问题