我需要使用curl 命令行实用程序将多个文件上传到服务器。对于单个文件,我使用以下命令没有问题:
curl -F "[email protected] /cdn-cgi/l/email-protection" http://localhost:8888/web/Upload.php
我该如何处理多个文件,以便 php 变量 $_FILES["image"]["error"] 返回一个数组?
我试过了
curl -F "[email protected] /cdn-cgi/l/email-protection" -F "[email protected] /cdn-cgi/l/email-protection" http://localhost:8888/web/Upload.php
curl -F "[email protected] /cdn-cgi/l/email-protection,[email protected] /cdn-cgi/l/email-protection" http://localhost:8888/web/Upload.php
但这些都是在黑暗中进行的。
诀窍是将文件上传参数命名为唯一的。
curl -F "[email protected] /cdn-cgi/l/email-protection" -F "[email protected] /cdn-cgi/l/email-protection" http://localhost:8888/web/Upload.php
这将显示在$_FILES
超全局作为$_FILES['image']
and $_FILES['image2']
.
使文件归为一个$_FILES
索引您需要将参数命名为数组:
curl -F "image[][email protected] /cdn-cgi/l/email-protection" -F "image[][email protected] /cdn-cgi/l/email-protection" http://localhost:8888/web/Upload.php
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)