저는 CodeIgniter를 사용하여 프로젝트를 개발 중입니다. 나는 원격 서버에서 이미지를 다운로드하려고하면, 나는 fallowing 오류가 :file_put_contents 특정 오류가 발생했습니다
ERROR :
Message: file_put_contents(): supplied resource is not a valid stream resource
오류가 발생 코드 : addImageWhiteSpaces에서
$newImg = resizeImageFrontDimensions($uploadData, UPLOAD_DEFAULT_IMGTHUMB50, UPLOAD_DEFAULT_IMGTHUMB50);
$imageWhiteFilled = addImageWhiteSpaces(UPLOAD_DEFAULT_IMGTHUMB50, $fileType, DIR_SCREENS . $newImg);
file_put_contents(DIR_SCREENS, $imageWhiteFilled);
:
function addImageWhiteSpaces($imageSize, $fileType, $fileName)
{
switch($fileType)
{
case DEFAULT_IMAGE_FILETYPE_PNG:
$image1 = imagecreatefrompng($fileName);
break;
case DEFAULT_IMAGE_FILETYPE_JPG:
$image1 = imagecreatefromjpeg($fileName);
break;
case DEFAULT_IMAGE_FILETYPE_JPEG:
$image1 = imagecreatefromjpeg($fileName);
break;
case DEFAULT_IMAGE_FILETYPE_GIF:
$image1 = imagecreatefromgif($fileName);
break;
}
$image1_x = imagesx($image1);
$image1_y = imagesy($image1);
if($image1_x > 500 && $image1_y > 500)
return $fileName;
else
{
switch ($imageSize)
{
case UPLOAD_DEFAULT_IMGTHUMB50:
$image_bg = imagecreatefrompng(PATH_MEDIA_IMG . 'white_bg_50.png');
break;
case UPLOAD_DEFAULT_IMGTHUMB74:
$image_bg = imagecreatefrompng(PATH_MEDIA_IMG . 'white_bg_74.png');
break;
case UPLOAD_DEFAULT_IMGTHUMB114:
$image_bg = imagecreatefrompng(PATH_MEDIA_IMG . 'white_bg_114.png');
break;
case UPLOAD_DEFAULT_IMGTHUMB300:
$image_bg = imagecreatefrompng(PATH_MEDIA_IMG . 'white_bg_300.png');
break;
case UPLOAD_DEFAULT_IMGTHUMB500:
$image_bg = imagecreatefrompng(PATH_MEDIA_IMG . 'white_bg_500.png');
break;
}
$image_bg_x = imagesx($image_bg);
$image_bg_y = imagesy($image_bg);
$imageStart_x = 0;
$imageStart_y = 0;
if($image_bg_y > $image1_y)
$imageStart_y = ($image_bg_y - $image1_y)/2;
if($image_bg_x > $image1_x)
$imageStart_x = ($image_bg_x - $image1_x)/2;
imagecopy($image_bg, $image1, $imageStart_x, $imageStart_y, 0, 0, $image1_x, $image1_y);
// Output the image.
// header("Content-type: image/png");
// imagejpeg($image_bg);
return $image_bg;
}
을
이 오류가 발생해도 이미지가 다운로드되고 있습니다. 그러나 위의 오류를 제공하기 때문에 이미지를 다운로드하고 나머지 코드를 계속 진행할 수 없습니다. 가능한 해결책이나 이유는 나를위한 금고입니다. 많은 감사합니다.
GD not imagemagick을 사용 중이며 Imagemagick 태그를 GD로 변경합니다. – Bonzo