Content-Disposition attachment

conpodrg

New Member
Messages
3
Reaction score
0
Points
0
let said i have 2 server.
www.domain.com , # 1 server
sub1.domain.com , #2 server

the file is on #2 server. in www.domain.com i use content-disposition for the user but #1 will download the file then give to user.
is there a way to load directly from #2?
 

misson

Community Paragon
Community Support
Messages
2,572
Reaction score
72
Points
48
Your issue isn't at all clear. What URL does the user access? Where is this URL used? Take us through the steps. Make sure you read the question asking guides linked to in my sig. If you're asking about some sort of program, post a self-contained and concise source code sample. We could also use live links to sample pages, rather than made-up URLs.
 
Last edited:

conpodrg

New Member
Messages
3
Reaction score
0
Points
0
I'm trying to do something with php header that allow people to download the image but without knowing it exact location.

Now i don't have 2 servers, so i have to test it on my pc [XAMPP] and other any file on the internet, i'm using google logo as example.

the code below:

PHP:
<?php
header('Content-type: image/png');
header('Content-Disposition: attachment; filename="test.png"');
readfile('http://www.google.com/images/logos/ps_logo2.png');
?>
my traffic said apache connect to google download the image then send it to me, is there a way directly connect to google and download the file. Does this happen because of the different domain ? Will that happen if it the same domain like www.domain.com and other server is subdomain.domain.com
 

misson

Community Paragon
Community Support
Messages
2,572
Reaction score
72
Points
48
my traffic said apache connect to google download the image then send it to me, is there a way directly connect to google and download the file.
Is this supposed to be a question? Since the resource resides on another host, your server either has to read it itself or tell the client where to find it by sending a redirect (i.e. setting a "Location" header). Think about it for a second: how is a client to fetch a resource directly without being told where to find it?

Does this happen because of the different domain ? Will that happen if it the same domain like www.domain.com and other server is subdomain.domain.com[?]
It happens because you're referring to the resource with an HTTP URL, which invokes the HTTP wrapper. Since the image is on a different host, there's no way your host can read it without opening a network connection. If the path passed to readfile is local file path (no scheme, or the "file:" scheme with no host or the local host), then no network connection is required.
 
Last edited:

conpodrg

New Member
Messages
3
Reaction score
0
Points
0
Yes the first one is a question, i forgot the question mark.
If i send redirect user will know the location of the image.

Do you know a way let them download but without the exact location? Is there something like a temporary link that will expire after a while on the subdomain.domain.com?
 
Top