note 40040 deleted from function.imagejpeg by cmb

From: Date: Sun, 02 Oct 2016 08:02:35 +0000
Subject: note 40040 deleted from function.imagejpeg by cmb
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-206729@lists.php.net to get a copy of this message
Note Submitter: php at andy-pearce dot com ---- This might be too obvious, but perhaps worth pointing out. If you want to simply serve images without altering them, it's presumably more efficient to use something like the following: <?php // Normally $filename would depend on $_GET, etc. $filename = '/photoalbum/images/test.jpg'; header('Content-type: image/jpeg'); header('Content-transfer-encoding: binary'); header('Content-length: '.filesize($filename)); readfile($filename); ?> That way you avoid the overhead of reading and parsing the image, you simply send it directly to the browser. This is particularly useful if you're using PHP to implement access controls, because it allows you to redirect files from areas of the filesystem browsers can't normally access (although the filename should always come from your script if possible, and not from a URL field, to prevent subverting it with URLs such as image.php?../../../etc/passwd).

« previous php.notes (#206729) next »