当前位置:Gxlcms > PHP教程 > 七牛云存储-如何使用php上传大文件到七牛云储?

七牛云存储-如何使用php上传大文件到七牛云储?

时间:2021-07-01 10:21:17 帮助过:69人阅读

按照官方文档写的简易上传, 上传大一点的文件或是中文名文件就会失败,如何解决?
index.php

index.php








upload.php

upload.php    
Token(null);
$putExtra = new Qiniu_PutExtra();
$putExtra->Crc32 = 1;
list($ret, $err) = Qiniu_PutFile($upToken, $key1,$_FILES["file"]["tmp_name"], $putExtra);
echo "====> Qiniu_PutFile result: \n";
if ($err !== null) {
    var_dump($err);
} else {
    var_dump($ret);
}
if ($_FILES["file"]["error"] > 0)
  {
  echo "Error: " . $_FILES["file"]["error"] . "
"; } else { echo "Upload: " . $_FILES["file"]["name"] . "
"; echo "Type: " . $_FILES["file"]["type"] . "
"; echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb
"; echo "Stored in: " . $_FILES["file"]["tmp_name"]; } ?> ?>

回复内容:

按照官方文档写的简易上传, 上传大一点的文件或是中文名文件就会失败,如何解决?
index.php

index.php








upload.php

upload.php    
Token(null);
$putExtra = new Qiniu_PutExtra();
$putExtra->Crc32 = 1;
list($ret, $err) = Qiniu_PutFile($upToken, $key1,$_FILES["file"]["tmp_name"], $putExtra);
echo "====> Qiniu_PutFile result: \n";
if ($err !== null) {
    var_dump($err);
} else {
    var_dump($ret);
}
if ($_FILES["file"]["error"] > 0)
  {
  echo "Error: " . $_FILES["file"]["error"] . "
"; } else { echo "Upload: " . $_FILES["file"]["name"] . "
"; echo "Type: " . $_FILES["file"]["type"] . "
"; echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb
"; echo "Stored in: " . $_FILES["file"]["tmp_name"]; } ?> ?>

Qiniu_Rio_PutFile(...)试试…

或者直接从网页往七牛服务器传…有基于plupload的前端SDK…

这里有示例和代码下载:http://7niu.sinaapp.com/

人气教程排行