0

我正在尝试上传图片,但我收到此错误 这是我收到的错误 我不知道该怎么做

  1. 我尝试更改“src”,但图片无法上传。
  2. 我尝试更改 file_put_contents 但这不起作用。

    静态函数 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 . '"/>';
    }  }
    
4

0 回答 0