七牛 图片上传问题
程序员文章站
2022-05-27 14:00:47
...
在用七牛云上传图片时,出现了以下错误
Fatal error: Uncaught exception 'Exception' with message 'file can not open' in /var/www/html/includes/src/Qiniu/Storage/UploadManager.php:91 Stack trace: #0 /var/www/html/includes/cls_image.php(150): QiniuStorageUploadManager->putFile('2kHh1HThkNyWvGL...', 'images/201609/g...', 'images/201609/s...') #1 /var/www/html/admin/goods.php(1132): cls_image->qiniuUpload('images/201609/s...', 'goods_img') #2 {main} thrown in /var/www/html/includes/src/Qiniu/Storage/UploadManager.php on line 91
Fatal error: Uncaught exception 'Exception' with message 'file can not open' in /var/www/html/includes/src/Qiniu/Storage/UploadManager.php:91 Stack trace: #0 /var/www/html/includes/cls_image.php(150): QiniuStorageUploadManager->putFile('2kHh1HThkNyWvGL...', 'images/201609/g...', 'images/201609/s...') #1 /var/www/html/admin/goods.php(1132): cls_image->qiniuUpload('images/201609/s...', 'goods_img') #2 {main} thrown in /var/www/html/includes/src/Qiniu/Storage/UploadManager.php on line 91
回复内容:
在用七牛云上传图片时,出现了以下错误
Fatal error: Uncaught exception 'Exception' with message 'file can not open' in /var/www/html/includes/src/Qiniu/Storage/UploadManager.php:91 Stack trace: #0 /var/www/html/includes/cls_image.php(150): QiniuStorageUploadManager->putFile('2kHh1HThkNyWvGL...', 'images/201609/g...', 'images/201609/s...') #1 /var/www/html/admin/goods.php(1132): cls_image->qiniuUpload('images/201609/s...', 'goods_img') #2 {main} thrown in /var/www/html/includes/src/Qiniu/Storage/UploadManager.php on line 91
请确认上传文件的路径是否有值。即
$_FILES['input-file-name']['tmp_name']
七牛云代码定位如下:
public function putFile(
$upToken,
$key,
$filePath,
$params = null,
$mime = 'application/octet-stream',
$checkCrc = false
) {
$file = fopen($filePath, 'rb'); //文件不存在,或者不可读
if ($file === false) { //文件为空
throw new \Exception("file can not open", 1); //抛出错误的地方
}
$params = self::trimParams($params);
$stat = fstat($file);
$size = $stat['size'];
if ($size config,
$params,
$mime,
$checkCrc
);
}
$up = new ResumeUploader(
$upToken,
$key,
$file,
$size,
$params,
$mime,
$this->config
);
$ret = $up->upload();
fclose($file);
return $ret;
}
上一篇: H5学习之旅-H5的样式(5)
下一篇: 怎么才能学好php 如何才算是学好php
推荐阅读
-
yii2整合百度编辑器umeditor及umeditor图片上传问题的解决办法
-
android递归压缩上传多张图片到七牛的实例代码
-
spring boot实现上传图片并在页面上显示及遇到的问题小结
-
Python的Django中将文件上传至七牛云存储的代码分享
-
HTML5实现简单图片上传所遇到的问题及解决办法
-
微信JSSDK多图片上传并且解决IOS系统上传一直加载的问题
-
IOS中html5上传图片方向问题解决方法
-
android递归压缩上传多张图片到七牛的实例代码
-
vuejs开发组件分享之H5图片上传、压缩及拍照旋转的问题处理
-
http图片上传安全性问题 根据ContentType (MIME) 判断其实不准确、不安全