带有php的Docker,文件上传失败,$ _ FILE为空

时间:2018-11-12 02:39:24

标签: php docker

奇怪的是,仅在本地环境中上传失败,它在生产环境和开发环境中起作用。所有这些都使用docker来运行项目,并在docker中检查了我的本地php.ini。设置正确,以下是有关我的文件上传的一些信息

发布数据:

------------KM7GI3GI3Ef1ei4ae0gL6GI3GI3Ij5
Content-Disposition: form-data; name="Filename"

test.pdf
------------KM7GI3GI3Ef1ei4ae0gL6GI3GI3Ij5
Content-Disposition: form-data; name="PHPSESSID"

<?php echo session_id(); ?>
------------KM7GI3GI3Ef1ei4ae0gL6GI3GI3Ij5
Content-Disposition: form-data; name="fileNameFormat"

{time}{rand:6}
------------KM7GI3GI3Ef1ei4ae0gL6GI3GI3Ij5
Content-Disposition: form-data; name="upfile"; filename="test.pdf"
Content-Type: application/octet-stream


------------KM7GI3GI3Ef1ei4ae0gL6GI3GI3Ij5
Content-Disposition: form-data; name="Upload"

Submit Query
------------KM7GI3GI3Ef1ei4ae0gL6GI3GI3Ij5--

php部分:

<?php var_dump($_FILE);?>

结果:

NULL

我的php.ini的部分设置

post_max_size = 2000M

max_input_time = 6000000000000000000000000000000000000000000

memory_limit = 1280M

;;;;;;;;;;;;;;;;
; 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 = 2000M

; Maximum number of files that can be uploaded via a single request
max_file_uploads = 2000000000000000000000000000000000000000000

1 个答案:

答案 0 :(得分:1)

max_input_timeupload_max_filesize设置为一个通用值,例如3000。这两个设置的值太大,如果php无法接受它。我将这些设置重置为3000,然后重新启动容器。现在文件上传可以成功进行了。