Home >Backend Development >PHP Tutorial >七牛云存储 - PHP uploadify 传图片失败

七牛云存储 - PHP uploadify 传图片失败

WBOY
WBOYOriginal
2016-06-06 20:47:291011browse

后端 是PHP,上传图片使用 js uploadify

uploadifg 相关配置
fileObjName: 'file',
formData: {'token':uptoken},
这个uptoken 是 如下得来的

<code>$putPolicy = new Qiniu_RS_PutPolicy($this->bucket);
$upToken   = $putPolicy->Token(null);
</code>

我在自己的服务器上有保持一份传上来的图片,然后再调用七牛的接口

<code>$putPolicy = new Qiniu_RS_PutPolicy($this->bucket);
$upToken   = $putPolicy->Token(null);
$putExtra  = new Qiniu_PutExtra();

$putExtra->Crc32 = 1;
list($ret, $err) = Qiniu_PutFile($upToken, $src, __file__, $putExtra);

return array("ret"=> $ret,"err" =>$err);
</code>

显示成功 返回结果如下

Array( [ret] => Array ( [hash] => FkGopI0P0Cf1ugA3CIvwvXUxI9Eh [key] => 3010020140124220707.png ) [err] => );

但是当我获取下载图片链接时,下载下来的图片是损坏的,我在七牛的内容管理那么的图片也是不能预览的,请问是不是我哪一个步骤出错了?

回复内容:

后端 是PHP,上传图片使用 js uploadify

uploadifg 相关配置
fileObjName: 'file',
formData: {'token':uptoken},
这个uptoken 是 如下得来的

<code>$putPolicy = new Qiniu_RS_PutPolicy($this->bucket);
$upToken   = $putPolicy->Token(null);
</code>

我在自己的服务器上有保持一份传上来的图片,然后再调用七牛的接口

<code>$putPolicy = new Qiniu_RS_PutPolicy($this->bucket);
$upToken   = $putPolicy->Token(null);
$putExtra  = new Qiniu_PutExtra();

$putExtra->Crc32 = 1;
list($ret, $err) = Qiniu_PutFile($upToken, $src, __file__, $putExtra);

return array("ret"=> $ret,"err" =>$err);
</code>

显示成功 返回结果如下

Array( [ret] => Array ( [hash] => FkGopI0P0Cf1ugA3CIvwvXUxI9Eh [key] => 3010020140124220707.png ) [err] => );

但是当我获取下载图片链接时,下载下来的图片是损坏的,我在七牛的内容管理那么的图片也是不能预览的,请问是不是我哪一个步骤出错了?

您好!我认真看了一下,__file__这里有问题,上传的是php源代码,所以您看不到图片。

http://www.widuu.com/archives/11/832.html你可以看看我以前做的

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn