代码如下: 
 
        $oss_sdk_service = new ALIOSS();      
        $oss_sdk_service->set_debug_mode(FALSE);          
         
        $bucket = 'xxxx';  
        $object = 'oss-file-name-'.time().'.jpg';      
         
        $pathFile = "C:/1.jpg";         
     
        $upload_file_options = array(  
            'content' => fopen($pathFile, 'r'), 
            'length' => filesize($pathFile), 
        );          
        $upload_file_by_content = $oss_sdk_service->upload_file_by_content($bucket,$object,$upload_file_options);  
        print_r($upload_file_by_content);die();

然后报错: 
  exception 'OSS_Exception' with message 'Http Body的内容非法',但是采用upload_file_by_file上传是可以的

解决如下:

  你传入的是一个文件的句柄,并没有读取内容。应该改成这样:content' => file_get_contents($pathFile),

PHP1.0版本上传OSS报错,仿照2.0版本传入的居然是句柄的更多相关文章

  1. 上传OSS报错

    修改OSS

  2. rz上传文件报错:rpm Read Signature failed: sigh blob(1268): BAD, read returned 0

    上传文件报错: [root@www localdisk]# rpm -ivh cobbler* error: cobbler-2.8.4-4.el7.x86_64.rpm: rpm  Read  Si ...

  3. Linux - xshell上传文件报错乱码

    xshell上传文件报错乱码,解决方法 rz -be 回车 下载sz  filename

  4. Azkban上传文件报错installation Failed.Error chunking

    azkaban 上传文件报错Caused by: java.sql.SQLException: The size of BLOB/TEXT data inserted in one transacti ...

  5. Tomcat上传文件报错:returned a response status of 403 Forbidden

    出现这样的错误是没有权限对服务器进行写操作.需要在这个项目所在的tomcat中配置可写操作即可: 在tomcat的web.xml添加下面代码: <init-param><param- ...

  6. SecureCRT sftp上传文件报错:put: failed to upload xxx 拒绝访问

    1.问题 使用sftp上传文件时报错:put: failed to upload xxx 拒绝访问.类似下图所示: 2.原因 造成这个问题的原因可能有两个,一是要上到的那个目录剩余磁盘空间不足,二是打 ...

  7. 【大数据系列】hadoop上传文件报错_COPYING_ could only be replicated to 0 nodes

    使用hadoop上传文件 hdfs dfs -put  XXX 17/12/08 17:00:39 WARN hdfs.DFSClient: DataStreamer Exception org.ap ...

  8. Windows 7上执行Cake 报错原因是Powershell 版本问题

    在Windows 7 SP1 电脑上执行Cake的的例子 http://cakebuild.net/docs/tutorials/getting-started ,运行./Build.ps1 报下面的 ...

  9. 上传文件报错System.Net.ProtocolViolationException: 必须先将 ContentLength 字节写入请求流,然后再调用 [Begin]GetResponse。

    在上传文件的时候报错. 错误: System.Net.ProtocolViolationException: 必须先将 ContentLength 字节写入请求流,然后再调用 [Begin]GetRe ...

随机推荐

  1. JAVA基础--toString, equals方法

    ==比较的是地址 equals比较的是内容. 所以要重写object的equals方法. public class TestEquals { public static void main(Strin ...

  2. treeview 与tabControl组合使用

    1.左边一个treeview,右边一个tabcontrol: 2.调整控件让tree在tabcontrol上,并让treeview压住tab页 3.将tab页的name设置成treeview的node ...

  3. office web apps部署(一)

    准备两台服务器,A服务器作为域控制器,B服务器安装owa 1.配置域服务器A 参考 2.B服务器加入A所创建的域 参考 3.B服务器安装owa 参考 注意: 1.B服务器加入域后,使用A服务器的管理员 ...

  4. jemalloc Mongodb Nginx 优化

    下载 http://www.canonware.com/jemalloc/download.html 下载 wget http://www.canonware.com/download/jemallo ...

  5. (简单) POJ 1278 Catch That Cow,回溯。

    Description Farmer John has been informed of the location of a fugitive cow and wants to catch her i ...

  6. RSA----实际函数库选择

    需求:对字符串加密 加密后不要超过这个字符串的长度,最好是1半的长度. 非对称算法. 重复度一定要低 1使用RSA加密 1   rsaeuro 2openssl    参考openssl编程 3 Cr ...

  7. HDU 5652 India and China Origins

    二分答案+验证,注意一开始就不连通的话输出0 #include<cstdio> #include<cstring> #include<cmath> #include ...

  8. HDU 5620 KK's Steel

    想了一下发现是斐波那契数列.....水题 #include <stdio.h> #include <algorithm> #include <string.h> # ...

  9. HTML 基础语言

      打开DREAMWEAVER,新建HTML.. body的属性: bgcolor                页面背景色 background            背景壁纸.图片 text    ...

  10. js中的 substring和substr方法

    原文: http://www.cnblogs.com/chinafine/archive/2009/02/26/1398771.html 1.substring 方法 定义和用法 substring ...