Rumah > pembangunan bahagian belakang > tutorial php > 七牛 图片上传问题

七牛 图片上传问题

WBOY
Lepaskan: 2016-09-08 08:44:00
asal
2050 orang telah melayarinya

在用七牛云上传图片时,出现了以下错误
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']

七牛云代码定位如下:

<code>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;
    }</code>
Salin selepas log masuk
Label berkaitan:
php
sumber:php.cn
Kenyataan Laman Web ini
Kandungan artikel ini disumbangkan secara sukarela oleh netizen, dan hak cipta adalah milik pengarang asal. Laman web ini tidak memikul tanggungjawab undang-undang yang sepadan. Jika anda menemui sebarang kandungan yang disyaki plagiarisme atau pelanggaran, sila hubungi admin@php.cn
Tutorial Popular
Lagi>
Muat turun terkini
Lagi>
kesan web
Kod sumber laman web
Bahan laman web
Templat hujung hadapan