<form action="http://www.s1989.com/subject/photo" method="post" enctype="multipart/form-data" style="width:300px;margin:0 auto;margin-top:120px;">
<div style="height:100px;width:220px;">
<label>session</label>
<input type="text" name="session" value="e878c6f1-414b-4b23-ad50-ecf606ff7d37">
</div>
<div style="height:100px;width:220px;">
<label>subject_id</label>
<input type="text" name="subject_id" value="1">
</div>
<div style="height:100px;width:220px;">
<label>photo</label>
<input name="photo" type="file" accept="image/gif, image/jpeg"/>
</div>
<input type="submit" value="上去把皮卡丘">
</form>
这种形式访问接口可以上传图片,
但是我在PHP里面$_FILES['photo'] 获取赋值提交给curl接口就参数错误。
谁可以帮忙按照我这个写一个模拟提交的curl,一共三个参数,参数session
subject_id 以及图片photo
curl -G http://www.s1989.com/subject/photo/ \ -d "session=e878c6f1-414b-4b23-ad50-ecf606ff7d37" \ -d "subject_id=1" \ -d "photo=这里改成文件路径"
很简单,浏览器里面提交,同时用f12抓包,然后你程序照着写。