我正在使用 ApacheBench 对 PHP 图像上传模块进行基准测试。问题是,当我转储时,$_FILES["my_file"]
我可以看到 PHP 存储的临时文件不是图像文件,而是 base64(文本/纯文本)文件。鉴于POST
请求告诉它上传文件的内容类型是,PHP 不应该将该文件存储为图像文件image/jpeg
吗?或者 PHP 的行为是否符合预期,我的工作是处理其中的二进制数据$_FILES["my_file"]["tmp_name"]
?
这是我运行ab的方式:
$>ab -v 4 -n 10 -c 2 -p /home/post_data.txt -T "multipart/form-data;\
boundary=1234567890" http://localhost/image_upload
以下是 /home/post_data.txt 的内容:
--1234567890
Content-Disposition: form-data; name="token"
Content-Type: text/plain
1
--1234567890
Content-Disposition: form-data; name="text"
Content-Type: text/plain
Testing
--1234567890
Content-Disposition: form-data; name="status"
Content-Type: text/plain
1
--1234567890
Content-Disposition: form-data; name="uploaded_file"; filename="my_image.jpg"
Content-Type: image/jpeg
Content-Transfer-Encoding: binary
[[base64 image data]]
--1234567890--
[请注意,我尝试删除"Content-Type: text/plain"
,但似乎没有任何区别]
谢谢!