假如给你一个API接口,这个接口是一个图片上传接口,禁止跨域AJAX上传图片,除了简单的浏览器Form表单上传之外,我们还可以使用CURL模拟表单上传。
相关知识点
1、AJAX提交表单
2、CURL发起POST请求
3、JSON数据解析
4、CSS美化File控件
5、JS一键复制
API接口
URL
NAME
http://my.zol.com.cn/index.php?c=Ajax_User&a=uploadImg
myPhoto
前端代码
AJAX图片上传-ZOL接口*{margin:0;padding: 0;}
#btn{
width: 120px;
height: 45px;
background: #39f;
line-height: 45px;
text-align: center;
color: #fff;
}
#file_select{
width: 130px;
height: 50px;
background: #333;
margin:20px auto;
line-height: 50px;
text-align: center;
color: #fff;
font-size: 16px;
}
#file_select .file_upload{
opacity: 0;
position: relative;
top: -65