用CULR向七牛的API上传文件

每次总是invalid multipart format

但是我已经设置了Content-type:multipart/form-data呀

function uploadFile($localPath, $remoteFileName, $headers=array()){

global $conf;

$remoteFileName = trim($remoteFileName,'/');

$policy = array('scope' => $conf['bucket'] . ':' . $remoteFileName, 'deadline' => time() + 3600);

$encodedFlags = encode(json_encode($policy));

$sign = hash_hmac('sha1', $encodedFlags, $conf['sk'], true);

$encodedSign = encode($sign);

$token = $conf['ak'].':'.$encodedSign. ':' . $encodedFlags;

$fields = array(

'token' => $token,

'key' => $remoteFileName,

'file' => '@'.$localPath

);

$curl = Magecho_HttpClient::get();

$curl->setOptions(array('gzip'=>false))->setHeader(array(

'Content-type:multipart/form-data'

))->post($conf['host']['up'] ,$fields);

return $curl->response();

}

function encode($str) {

$find = array('+', '/');

$replace = array('-', '_');

return str_replace($find, $replace, base64_encode($str));

}

$result = uploadFile('pic.jpg',date('Y-m-d-H-i-s').'.jpg');

echo $result;

php content-type: multipart/mixed,{error:invalid multipart format} 这是什么原因,我已经在HEADER中设置了Content-...相关推荐

  1. Oracle报错:IO Error: Invalid number format for port number

    这个原因是因为最后的连接url 应该是斜杠 参考:https://blog.csdn.net/qq_21383435/article/details/100111116

  2. Echarts 报错 Uncaught Error: Invalid geoJson format coordinate.charCodeAt is not a function

    地图 下钻时 ,同一个区域点击多次会出现 如下图 报错 原因是 每次引入的JSON文件都是新的,应该对绘图所需的JSON文件进行缓存 因为 echarts 会绘制解析 json 之后 执行 decod ...

  3. html multipart/form-data,深刻解析 multipart/form-data

    一个 HTML 表单中的 enctype 有三种类型 application/x-www-urlencoded multipart/form-data text-plain 默认状况下是 applic ...

  4. 阿里云存储OSS中设置上传文件content type

    阿里云存储OSS中设置上传文件ContentType 如果你使用浏览器上传文件,则浏览器会自动在header中设置正确地content type,然后对文件的访问会得到正确地回应. 如果采用编程的方式 ...

  5. Sharepoint学习笔记—Site Definition系列-- 2、创建Content Type

    Sharepoint本身就是一个丰富的大容器,里面存储的所有信息我们可以称其为"内容(Content)",为了便于管理这些Conent,按照人类的正常逻辑就必然想到的是对此进行&q ...

  6. Sharepoint学习笔记—ECM系列—1 Content Type Syndication

    我们可以通过Content Type Syndication来实现在Sharepoint Farm内的不同Site Collection之间共享内容类型(Content Types).也就是说,管理员 ...

  7. SharePoint2010 内容类型剖析(Content Type/ 內容類型)

    原文地址:http://sharepoint410.wordpress.com/2011/01/06/sharepoint2010-%E5%86%85%E5%AE%B9%E7%B1%BB%E5%9E% ...

  8. 关于centos docker版本过低导致 is not a valid repository/tag: invalid reference format

    1. 在执行 docker build . --no-cache -t xxx 命令时,报 Error parsing reference: "xxx/ubuntu20.04:117486 ...

  9. Invalid number format for port number(链接ORACLE时忘记加端口出现的错误)

    错误:java.sql.SQLException: Invalid number format for port number 原因:连接oracle时端口号错误: 解决: jdbc:oracle:t ...

最新文章

  1. js中对象的私有属性和公有属性
  2. 【模拟】【codeforces】451B Sort the Array
  3. 不能不知道的Docker知识
  4. Apache开源项目
  5. HeartBeat Install
  6. android.mk 翻译,翻译ANDROID-MK.TXT
  7. Stomp-Spring服务器端的Web套接字Java客户端
  8. [Kali][VMware][2020][窗口大小][分辨率]高分辨率自适应
  9. android加一减一控件,Android的步进器(增加/减少值)控件?
  10. OSPF Sham-Link
  11. 百度云网页视频加速播放
  12. 电机控制程序设计经验
  13. 限时免费领超大15.9GB的PS设计素材
  14. 如何成为一名优秀设计师?(锤子科技视觉总监罗子雄演讲实录)
  15. HTML .CSS实现商品详情(detail)
  16. hdu4889Scary Path Finding Algorithm【构造】搞坏spfa-slf 2014多校联合
  17. SpringSecurity 403 forbidden
  18. UE4中HUD、UMG、Slate之间的区别
  19. 让进度条颜色渐变的shader
  20. python异步查询数据库_Python的Tornado框架实现异步非阻塞访问数据库的示例

热门文章

  1. MongoDB复制集技术
  2. iOS 检查指定日期是否在当前日期之前
  3. flume package遇到的问题
  4. 解决yum命令失效,vim: command not found
  5. 信息安全官谁:逼近的挑战,你准备好了吗?
  6. Java异常处理机制很有意思
  7. linux下ORACLE的Sqlplus命令
  8. 证监会:《证券期货业信息安全保障管理办法(征求意见稿) 》公开征求意见...
  9. linux下VMware_Tools虚拟机工具的安装
  10. 有趣的Web版Ubuntu Linux