我需要使用curl命令行实用程序将多个文件上传到服务器.对于单个文件我使用时没有问题:
curl -F "image=@file1.gif" http://localhost:8888/web/Upload.php
Run Code Online (Sandbox Code Playgroud)
我怎么会做这样一个以上的文件,使PHP变量$ _FILES ["形象"] ["错误"]会返回一个数组?
我试过了
curl -F "image=@file1.gif" -F "image=@file2.gif" http://localhost:8888/web/Upload.php
curl -F "image=@file1.gif,image=@file2.gif" http://localhost:8888/web/Upload.php
Run Code Online (Sandbox Code Playgroud)
但这些都是在黑暗中刺伤.
com*_*857 42
诀窍是将文件上传参数命名为唯一.
curl -F "image=@file1.gif" -F "image2=@file2.gif" http://localhost:8888/web/Upload.php
Run Code Online (Sandbox Code Playgroud)
这将在$_FILES超全球中显示为$_FILES['image']和$_FILES['image2'].
要将文件分组在一个$_FILES索引下,您需要将参数命名为数组:
curl -F "image[]=@file1.gif" -F "image[]=@file2.gif" http://localhost:8888/web/Upload.php
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
24716 次 |
| 最近记录: |