This code shows the image in an image viewer with a file save or openwith. In fact, I want to ask only for users, what am I doing?

<?php $img=$_GET['im']; $im="http://localhost/proj1/images/PICS/$img"; $contents= file_get_contents("$im"); $output_file = 'image.jpg'; header("Content-Disposition: attachment; filename=" . $output_file); header("Content-Type: image/jpg"); //header('Content-Length: ' . filesize($contents)); echo $contents; exit(); ?> 
+4
source share
1 answer

You have no such choice. If you specify Content-Disposition: attachment , the browser will download the file. How exactly does it depend on the browser. Safari or Chrome simply downloads the file to disk without any hint whatsoever . Other browsers ask. You cannot control it.

+1
source

All Articles