>  기사  >  백엔드 개발  >  Qiniu 사진 업로드 문제

Qiniu 사진 업로드 문제

WBOY
WBOY원래의
2016-09-08 08:44:001999검색

Qiniu Cloud를 사용하여 사진을 업로드할 때 다음 오류가 발생했습니다
치명적인 오류: /var/www/html/includes/src/Qiniu/Storage /UploadManager에서 '파일을 열 수 없습니다' 메시지와 함께 포착되지 않은 '예외' 예외 .php:91 스택 추적: #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}은 91행의 /var/www/html/includes/src/Qiniu/Storage/UploadManager.php에 포함됩니다

답글 내용:

Qiniu Cloud를 사용하여 사진을 업로드할 때 다음 오류가 발생했습니다
치명적인 오류: /var/www/html/includes/src/Qiniu/Storage /UploadManager에서 '파일을 열 수 없습니다' 메시지와 함께 포착되지 않은 '예외' 예외 .php:91 스택 추적: #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}은 91행의 /var/www/html/includes/src/Qiniu/Storage/UploadManager.php에 포함됩니다

업로드한 파일의 경로에 값이 ​​있는지 확인해주세요. 그게

$_FILES['input-file-name']['tmp_name']

Qiniu Cloud 코드 위치는 다음과 같습니다.

<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::BLOCK_SIZE) {
            $data = fread($file, $size);
            fclose($file);
            if ($data === false) {
                throw new \Exception("file can not read", 1);
            }
            return FormUploader::put(
                $upToken,
                $key,
                $data,
                $this->config,
                $params,
                $mime,
                $checkCrc
            );
        }
        $up = new ResumeUploader(
            $upToken,
            $key,
            $file,
            $size,
            $params,
            $mime,
            $this->config
        );
        $ret = $up->upload();
        fclose($file);
        return $ret;
    }</code>
성명:
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.