Reputation: 2362
My Android app downloads images from my webspace. I have no ssl. I don't want the user to see where the images are stored. The folder with images should be secured via .htaccess. So I thought to send the GET request to a php script and it collects the image and responses it to the android client.
Can someone give me a hint how to do the forwarding?
Upvotes: 0
Views: 92
Reputation: 22656
A good way to do this is to keep the images outside the webroot. This way they can't be accessed by going to a url. In the php you can then do something like:
//Check username/whatever
//Decide what file we want
$theFile = getTheFile();
//Display the file
header('Content-Type: image/jpeg');
readfile('../not/web/accessible/'.$theFile);
die();
Upvotes: 1
Reputation: 2989
To download something from somewhere else use curl
. You really should cache downloaded content on your server. Reconstructing GET request from $_GET and $_SERVER variables should be easy, just follow examples on linked page.
But I think you want to look at "reverse proxy". There are existing solution of enterprise quality for this task.
Upvotes: 0