note 38479 added to function.base64-decode

From: Date: Tue, 23 Dec 2003 17:16:50 +0000
Subject: note 38479 added to function.base64-decode
Groups: php.notes 
Request: Send a blank email to php-notes+get-62379@lists.php.net to get a copy of this message
I was wondering how to decode attached images within mails. Basically they are mostly JPEG files, so it was obviously to write a function that decodes JPEG images. I guess the plainest way to do so was the following: function base64_to_jpeg( $inputfile, $outputfile ) { /* read data (binary) */ $ifp = fopen( $inputfile, "rb" ); $imageData = fread( $ifp, filesize( $inputfile ) ); fclose( $ifp ); /* encode & write data (binary) */ $ifp = fopen( $outputfile, "wb" ); fwrite( $ifp, base64_decode( $imageData ) ); fclose( $ifp ); /* return output filename */ return( $outputfile ); } This function decodes the given inputfile (a filename!) and saves it to the given outputfile (a filename as well) and then returns the output filename for further usage (e.g. redirect, imagejpeg() and so on). I thought that might be helpful. ---- Manual Page -- http://www.php.net/manual/en/function.base64-decode.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+38479 Delete -- http://master.php.net/manage/user-notes.php?action=delete+38479&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+38479&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#62379) next »