link to .jpg, make save ato desktop ?
Moderator: General Moderators
-
scheinarts
- Forum Commoner
- Posts: 52
- Joined: Wed Jul 25, 2007 2:37 am
link to .jpg, make save ato desktop ?
Hi,
I am wondering if there is a way so that when a user clicks on a link that ends in .jpg, instead of opening the image in browser, it would just bring the save to desktop request. If it is possible, would it be the same code for Windows and Mac?
I know this is already natural in the case of .zip files, but no clue how to make it work for jpgs.
Any help greatly appreicated.
Thanks.
I am wondering if there is a way so that when a user clicks on a link that ends in .jpg, instead of opening the image in browser, it would just bring the save to desktop request. If it is possible, would it be the same code for Windows and Mac?
I know this is already natural in the case of .zip files, but no clue how to make it work for jpgs.
Any help greatly appreicated.
Thanks.
Using headers?
Code: Select all
<?
header("Content-type: Application/octet-stream");
header("Content-Disposition: attachment; filename=image.jpg");
readfile("jpgif/image.jpg");
?>-
scheinarts
- Forum Commoner
- Posts: 52
- Joined: Wed Jul 25, 2007 2:37 am
HTML LINK PAGE
PHP DOWNLOAD PAGE
Code: Select all
<a href="downloadimage.php?path=filepath.jpg" target=_blank>image download</a>PHP DOWNLOAD PAGE
Code: Select all
$path=$_GET['path'];
function ForceDownloadImage($path_to_image)
{
//get filename
$filename = basename($path_to_image);
//sent the right headers
header("Content-Transfer-Encoding: binary");
header("Content-Type: image/jpg");
header("Content-Disposition: attachment; filename=$filename");
//start feeding with the file
readfile($path_to_image);
}
ForceDownloadImage($path);-
scheinarts
- Forum Commoner
- Posts: 52
- Joined: Wed Jul 25, 2007 2:37 am
-
scheinarts
- Forum Commoner
- Posts: 52
- Joined: Wed Jul 25, 2007 2:37 am
-
scheinarts
- Forum Commoner
- Posts: 52
- Joined: Wed Jul 25, 2007 2:37 am
it's probably what feyd said
the image is downloading as a file with a php extension, if you change the extension of the "download.php" file to "download.jpg" you may be able to view the image... OR it may be downloading the jpg file and attaching some php source to the beginning of the file... *shrug*
I'll test it out on safari a bit later and see what i can come up with
the image is downloading as a file with a php extension, if you change the extension of the "download.php" file to "download.jpg" you may be able to view the image... OR it may be downloading the jpg file and attaching some php source to the beginning of the file... *shrug*
I'll test it out on safari a bit later and see what i can come up with