Reply to Re: Binary? I don't know

Your name:

Reply:


Posted by Lee on 07/08/06 05:15

Doesn't the mime type have to do with how you view it?

If I use this php code, then it still doesn't display properly. How do
I bring it in with it knowing that it should be in binary? I tried
using base64_encode or base64_decode in the code but it doesn't seem to
do the trick. I couldn't try something like convert_uuencode because I
don't have php5.
Thanks!

<?
$imageFile='graffiti.jpg';

// display the image
header("Content-Type: image/jpeg");
$content = file_get_contents( $imageFile);
// $content = base64_decode($content);
print $content;
?>

flamer die.spam@hotmail.com wrote:
> you need to set the mime type or yes it will be binary BS.
>
> type=image/jpeg
>
> have a look at how thumbnail generators do it.
>
> flamer.
>
> Lee wrote:
>
> > Hi, I am reading in a huge post request that represents an image with
> > the php file below. The resultant file should be in jpg format, but it
> > comes in weird. Below my php file, I show the beginning of a regular
> > jpg file and the beginning of what I actually write to the file. I'm
> > sure it's a conversion issue but I don't know what. Any help?
> >
> > <?
> > // open the log file
> > $filename='log.txt';
> > $imageFile='graffiti.jpg';
> >
> > // write the image to jpeg
> > $imageString = $_POST['image'];
> > $imageString = urldecode($imageString);
> > //$imageString = stripslashes($imageString);
> > $fpImage=fopen($imageFile,'w+b'); //remove the binary?
> > fwrite($fpImage,$imageString);
> > fclose($fpImage);
> >
> > // write to the log file
> > $str = $imageString;
> > $str = date('G:i:s',time()) . "\n\n" . $str;
> > $logFp=fopen($filename,'w+');
> > fwrite($logFp,$str);
> > fclose($logFp);
> >
> >
> > // display the log file
> > header("Content-type: text/plain");
> > include $filename;
> > ?>
> >
> > What I write to file:
> > ÿØÿà \0JFIF\0\0\0\0\0\0ÿÛ\0C\0 
> > 
> >  $.\' \",#(7),01444\'9=82<.342ÿÛ\0C 
> >
> > 2!!22222222222222222222222222222222222222222222222222ÿÀ\0��\"\0ÿÄ\0\0\0\0\0\0\0\0\0\0\0
> >
> > What a regular jpg looks like:
> > ÿØÿà\0JFIF\0\0\0\0\0\0ÿÛ\0C\0 
> > 
> >  $.\' \",#(7),01444\'9=82<.342ÿÛ\0C

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация