note 60068 added to function.imagepng

From: Date: Sat, 24 Dec 2005 21:17:42 +0000
Subject: note 60068 added to function.imagepng
Groups: php.notes 
Request: Send a blank email to php-notes+get-100668@lists.php.net to get a copy of this message
PNG images (as any image) can be stored in a MySQL blob field, but if you want to do this, you'll want to serialize the image stream into a better form. I would recommend base64_encode() and base64_decode(). (Just fopen() the file, fread() the contents in, base64_encode() the string, and fire off your SQL query (use addslashes()/stripslashes() to be more secure)). This has been posted an innumerable amount of times throughout the site, but it's still terrible that a lot of users simply don't understand this and use it to its full potential. I would also recommend that if you are doing images this way, to keep an image cache folder somewhere that PHP can access (possibly even somewhere off your webroot?). That way if your website is swamped with traffic it won't kill the SQL server. ---- Manual Page -- http://www.php.net/manual/en/function.imagepng.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+60068 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+60068&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+60068&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+60068&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+60068&report=yes&reason=useless Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+60068&report=yes&reason=non-english Delete: already in docs -- http://master.php.net/manage/user-notes.php?action=delete+60068&report=yes&reason=already+in+docs Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+60068&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+60068&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#100668) next »