doufei16736 2016-09-25 07:57
浏览 68

无法打开流:没有这样的文件或目录:file_put_contents

i am trying to upload image and i get this error this is the error i get i dont have any idea what to do

  1. i try to change 'src' but the picture cant upload.
  2. i try to change file_put_contents but this is doesn't work.

    static function updateUserImage() {

        global $root;
        $file = reset($_FILES);
        $fileType = strtolower($file['type']);
        $allowedExt = ajaxParams('allowedExt');
        if (key_exists($fileType, $allowedExt) && file_exists($file['tmp_name'])) {
    
            $fileData = @file_get_contents($file['tmp_name']);
            $height = intval(trim(str_ireplace('px', '', ajaxParams('picHeight'))));
            $width = intval(trim(str_ireplace('px', '', ajaxParams('picWidth'))));
            $md5 = md5($fileData);
            $fileName = 'cache/cstFiles/' . $md5 . '.' . $allowedExt[$fileType];       
            file_put_contents($root.$fileName,$fileData);
    
            if ($height > 0 && $width > 0) {
                $params[crpFileType] = $allowedExt[$fileType];
                $params[crpDestinationDir] = $root . 'cache/cstFiles/';
                $params[crpOverwriteOrig] = true;
                $params[crpResizeMethod] = 'resize';
                $resizedPic = copyResizedPic2($root . $fileName, $width, $height, $params);
            }
    
        $key = time() . rand();
        $_SESSION[__mypAjaxSessionKey__]['mypc_file'][$key] = $fileName;
        return '
            <img src="' . $fileName . '"/>
            <input hidden type="text" name="' . ajaxParams('inputName') . '" value="' . $key . '"/>';
    }  }
    
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥20 求个正点原子stm32f407开发版的贪吃蛇游戏
    • ¥15 正弦信号发生器串并联电路电阻无法保持同步怎么办
    • ¥15 划分vlan后,链路不通了?
    • ¥20 求各位懂行的人,注册表能不能看到usb使用得具体信息,干了什么,传输了什么数据
    • ¥15 个人网站被恶意大量访问,怎么办
    • ¥15 Vue3 大型图片数据拖动排序
    • ¥15 Centos / PETGEM
    • ¥15 划分vlan后不通了
    • ¥20 用雷电模拟器安装百达屋apk一直闪退
    • ¥15 算能科技20240506咨询(拒绝大模型回答)