代码如下: 
 
        $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. 基于POI的Excel导入导出(JAVA实现)

    今天做了个excel的导入导出功能,在这记录下. 首先现在相关poi的相关jar包,资源链接:http://download.csdn.net/detail/opening_world/9663247 ...

  2. C语言数据类型的表示范围

    1.C和C++语言中基本的数据类型有:字符型(char),整形(short, int, long), 浮点型(float, double)    类型 字节数 类型 字节数 char 1 short ...

  3. PAT (Advanced Level) 1005. Spell It Right (20)

    简单题. #include<iostream> #include<cstring> #include<cmath> #include<algorithm> ...

  4. 微信小程序tips集合:无法输入文字/随时查看页面/元素审查/点击事件/数据绑定

    1:编辑文档无法输入文字 出现这种情况一般是因为之前编辑的文档未保存,所有在其他文档输入的时候会自动输入到未保存的文档中,在文档暂时编辑完毕后要ctrl+s随手保存,不然会出现无法打字情况 2: 随时 ...

  5. 子数涵数·C语言——循环语句

      之前,我们讲过了编程中的三种结构(顺序.条件.循环),现在我们来看一下循环语句如何编写. 一.while循环语句(先判断后执行) 1 #include<stdio.h> 2 int m ...

  6. eclipse中安装配置maven

    1.首先说一下在windows中安装maven.非常简单... 到http://maven.apache.org/download.html中下载maven,截止笔者发文时,maven最新版本为mav ...

  7. Docker学习小计

    1.自动下载并且创建容器 Now verify that the installation has worked by downloading the ubuntu image and launchi ...

  8. BZOJ3270: 博物馆

    3270: 博物馆 Time Limit: 30 Sec  Memory Limit: 128 MBSubmit: 269  Solved: 147[Submit][Status][Discuss] ...

  9. CocoaPods 更新慢&swift版本适配

    一.更新慢的问题 使用CocoaPods来添加第三方类库,无论是执行pod install还是pod update都卡在了Analyzing dependencies不动 原因在于当执行以上两个命令的 ...

  10. UVa 10551 - Basic Remains

    题目大意:关于大数的mod和进制转换,直接使用Java的BigInteger类,正在copy式学习中... import java.io.*; import java.util.*; import j ...