+ Reply to Thread
Results 1 to 5 of 5

Thread: Content-Disposition attachment

  1. #1
    conpodrg is offline x10Hosting Member conpodrg is an unknown quantity at this point
    Join Date
    Dec 2010
    Posts
    3

    Content-Disposition attachment

    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?

  2. #2
    misson is offline x10 Spammer misson is a jewel in the rough
    Join Date
    Mar 2008
    Location
    Libertatia
    Posts
    2,506

    Re: Content-Disposition attachment

    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 by misson; 12-09-2010 at 12:38 AM.
    Be sure to read all pages linked in this post; they have further information that should prove useful. When asking for help, make sure you follow Eric Raymond's and Jon Skeet's guidelines for prompt, accurate responses. Please answer any questions I ask; they're not rhetorical (probably). Any posted code is intended as illustrative example, rather than a solution to your problem to be copied without alteration. Study it to learn how to write your own solution.
    Misson, not Mission.

  3. #3
    conpodrg is offline x10Hosting Member conpodrg is an unknown quantity at this point
    Join Date
    Dec 2010
    Posts
    3

    Re: Content-Disposition attachment

    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 Code:
    <?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

  4. #4
    misson is offline x10 Spammer misson is a jewel in the rough
    Join Date
    Mar 2008
    Location
    Libertatia
    Posts
    2,506

    Re: Content-Disposition attachment

    Quote Originally Posted by conpodrg View Post
    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?

    Quote Originally Posted by conpodrg View Post
    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 by misson; 12-10-2010 at 05:31 PM.
    Be sure to read all pages linked in this post; they have further information that should prove useful. When asking for help, make sure you follow Eric Raymond's and Jon Skeet's guidelines for prompt, accurate responses. Please answer any questions I ask; they're not rhetorical (probably). Any posted code is intended as illustrative example, rather than a solution to your problem to be copied without alteration. Study it to learn how to write your own solution.
    Misson, not Mission.

  5. #5
    conpodrg is offline x10Hosting Member conpodrg is an unknown quantity at this point
    Join Date
    Dec 2010
    Posts
    3

    Re: Content-Disposition attachment

    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?

+ Reply to Thread

Similar Threads

  1. php sendmail with attachment
    By multiling in forum Scripts & 3rd Party Apps
    Replies: 1
    Last Post: 04-26-2010, 07:18 AM
  2. Domain attachment problem
    By diwaker0 in forum Free Hosting
    Replies: 0
    Last Post: 04-17-2010, 09:20 AM
  3. Email Attachment Problem
    By DemonicDemon in forum Free Hosting
    Replies: 0
    Last Post: 10-05-2008, 05:42 PM
  4. PHP E-mail with attachment
    By gamerdude in forum Programming Help
    Replies: 1
    Last Post: 07-07-2008, 04:37 AM
  5. Image attachment
    By digitalpakrat in forum Free Hosting
    Replies: 0
    Last Post: 12-12-2007, 10:19 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers