0

I have created a simple php application that resizes pics.. so this is how the program goes, the server will provide the client an interface where to browse a picture, then after the client chose the pic to be resized it hits on the "RESIZE BUTTON" then the image goes to the server and the server resizes the picture then stores it in a temporary directory.. now the problem is how to set the server to send the resized pic to the client to download.

2
Contributors
1
Reply
2
Views
9 Years
Discussion Span
Last Post by langsor
0

I would send the path to the file back to a script on the browser and have people right-click to download the file from that link-path ... make sense?

Otherwise, with PHP you can set the headers to download the file -- but beware security holes allowing people to specify which files to download, since this can expose sensitive data on your server.

Something like this ... but I didn't test it so not 100% sure ...

header( 'Pragma: public' ); // required
header( 'Expires: 0' );
header( 'Cache-Control: must-revalidate, post-check=0, pre-check=0' );
header( 'Cache-Control: private', false ); // required for certain browsers
header( 'Content-Type: application/force-download' );
header( 'Content-Disposition: attachment; filename="'.$filename.'";' );
header( 'Content-Transfer-Encoding: binary' );
header( 'Content-Length: '.filesize( $filename ) );
print file_get_contents( $filename );

Good luck

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.