masterexploder / PHPThumb

PHP Thumbnail & Image Manipulation Library
http://phpthumb.gxdlabs.com
980 stars 264 forks source link

Cannot show image, headers have already been sent on MacOS #37

Closed lapsoft closed 12 years ago

lapsoft commented 13 years ago

PhpThumb.inc.php->loadPlugins ($pluginPath)

while (false !== ($file = readdir($handle))) { if ($file == '.' || $file == '..' || $file == '.svn') { continue; } echo $pluginPath . '/' . $file; include_once($pluginPath . '/' . $file); } What about folders like ".DS_Store" on MacOS ?

Now i've got: Bud1‡eflectgd_reflection.inc.phpIlocblobF(˙˙˙˙˙˙  @€ @€ @€ @ E‡DSDB ` @€ @€ @ Fatal error: Uncaught exception 'RuntimeException' with message 'Cannot show image, headers have already been sent' in /phpthumb/GdThumb.inc.php:569 Stack trace: #0 /thumb_examples/resize_basic.php(30): GdThumb->show() #1 {main} thrown in /www/ksi_templx/library/phpthumb/GdThumb.inc.php on line 569

lapsoft commented 13 years ago

I propose: if ($file == '.' || $file == '..' || $file == '.svn' || substr($file, 0, 1)=='.') { continue; }

nettles-jarrod commented 12 years ago

This sort of behavior happens when you output any sort of text and then try to send headers (PHPThumb will send an image header) - so if you output text before running PHPThumb it will generate an error.