Note that there are some explanatory texts on larger screens.

plurals
  1. POfile_put_contents give me a specific error
    text
    copied!<p>I am developing a project using CodeIgniter. When I try to download an image from remote server, I get the fallowing error:</p> <p>ERROR:</p> <pre><code>Message: file_put_contents(): supplied resource is not a valid stream resource </code></pre> <p>The code that causes error:</p> <pre><code> $newImg = resizeImageFrontDimensions($uploadData, UPLOAD_DEFAULT_IMGTHUMB50, UPLOAD_DEFAULT_IMGTHUMB50); $imageWhiteFilled = addImageWhiteSpaces(UPLOAD_DEFAULT_IMGTHUMB50, $fileType, DIR_SCREENS . $newImg); file_put_contents(DIR_SCREENS, $imageWhiteFilled); </code></pre> <p>In addImageWhiteSpaces:</p> <pre><code>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 &gt; 500 &amp;&amp; $image1_y &gt; 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 &gt; $image1_y) $imageStart_y = ($image_bg_y - $image1_y) / 2; if($image_bg_x &gt; $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; } </code></pre> <p>Although I get this error, the image is being downloaded. But because it gives the error above, I download the image and can not continue to rest of the code. Any possible solution or reason is a vault for me. Many thanks.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload