Trigger auto download of image

Soldato
Joined
6 Mar 2008
Posts
10,079
Location
Stoke area
Hi all,

Just looking at a way of scanning an NFC tag, following a URL to an image and instead of loading in a web page, it auto downloads (or asks to download) the image.

Any suggestions of where to look?

Thanks
 
Associate
Joined
10 Nov 2013
Posts
1,808
The webpage needs to return a 'content-disposition' header to the client to tell it that it's a file to download. In php it would be something like:

header("Content-Disposition: attachment; filename='image.png'");

You can set some other headers tell the client other things like what file type it is, etc. but that's the key one.
 
Back
Top Bottom