Note that there are some explanatory texts on larger screens.

plurals
  1. POPHP creates image file but only works on local dev, not at the remote server
    text
    copied!<p>I have a code that dinamically resizes an image and sends it to the browser.</p> <p>But it doesn't work properly... only if I ask it to output the image to a file instead of the browser.</p> <p>I don't think the problem is my code, because this problem <em>only occurs on the real server</em>; in my computer its working perfectly.</p> <p>Code:</p> <pre><code>$img = $_GET['img']; ini_set('allow_url_fopen', 'on'); $info = getimagesize($img); header('Content-type: '.image_type_to_mime_type($info[2])); Fotos::redimensiona($img, null, Fotos::MINIGAL_WIDTH, Fotos::MINIGAL_HEIGHT, false); </code></pre> <p>Fotos::redimensiona():</p> <pre><code>//[...] a whole bunch of code calculating dimensions, they just works // $funcImage is like 'imagejpeg'/'imagepng'/'imagegif', depends on file if ($arquivo) { $funcImage($thumb, "$final.$ext"); return "$final.$ext"; } else { $funcImage($thumb); } </code></pre> <p>Remember: it <strong>works</strong> on local development, but doesn't on remote web server.</p> <p><strong>[EDIT]</strong><br> if I comment the <code>header</code> line, the binary code is printed; and this code changes when i change the original image, as expected.<br> But with the <code>header</code> Firefox shows me the URL of the page (like <code>http://www.sabianoar.com.br/novosabia/inc/phpImg.php?img=awful_escaped_long_path.jpeg</code>), and if I do <code>CTRL+I</code> it tells me it is an JPEG of 0x0 size, and like 10kb.<br> Opera shows me an empty image, as it would do if I had placed an <code>&lt;img&gt;</code> with the wrong <code>src</code>, i.e.</p> <p><strong>[EDIT2]</strong> EyeOfGnome says "Not a JPEG file: starts with 0xef 0xbb" when I try to save and then open the output (it saves to a .jpeg file normally).</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