Reply to Re: download

Your name:

Reply:


Posted by Sjoerd on 07/12/07 12:36

Thorsten Kiefer wrote:
> Hi,
> I want to offer the user a file for download.
> For images I do this :
>
> <?php
> header ("Content-type: image/png");
> $im = imagecreatetruecolor(50, 25);
> $text_color = imagecolorallocate($im, 233, 14, 91);
> imagestring($im, 5, 5, 5, "bla", $text_color);
>
> imagepng($im);
> imagedestroy($im);
> ?>
>
> Now I'm wondering, what imagepng() exactly does ?!
> Because I want to offer an executable.
> My first idea was something like this :
>
> <?php
> header ("Content-type: application/executable");
> $x = file_get_contents("myexe");
> header($x);
> ?>
>
>
> Can anyone correct this please ??
>
> Thank you all very much !!
> Thorsten
>

header("Content-type: foo/bar") tells the browser what kind of file you
are serving. After that, you have to output the contents of the file.

imagepng outputs the image as a PNG.

Outputting a text file would go like this:
<?php
header("Content-type: text/plain");
echo "Hello world";
?>

Using echo $x; instead of header($x); would work in your example.

[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

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