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.

Member Avatar for langsor

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.