Re: downloading images

From: Date: Tue, 30 Oct 2001 04:07:22 +0000
Subject: Re: downloading images
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-72818@lists.php.net to get a copy of this message
On Mon, Oct 29, 2001 at 10:47:11AM -0800, Heidi Belal wrote: > I'd like users to be able to download images from on > my site. The images are pretty big, so i've made > thumbnails for each. I can display each thumbnail, > but how can i get it so that once the user clicks on > the thumbnail, they get to download the whole image. > I'd like it to work without having the user to right > click and choose 'save image as'. > Any ideas?! When the user clicks on a thumbnail, send them to a script which sets these headers, and outputs the image. You'll also want to include some code to make sure the script can't be used to send an arbitrary file to the user. <? Header('Content-Type: application/octet-stream'); Header('Content-Disposition: attachment; filename="' . $filename . '"'); readfile($filename); ?> This will tell the browser to download the file, rather than displaying it. Matt

« previous php.general (#72818) next »