Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 8 of 8
  1. #1
    Senior Member joncom11's Avatar
    Join Date
    Oct 2003
    Posts
    284
    Member #
    3532
    Help! I have no idea how this happened!! Ok.. so I have this header script:

    Code:
    <?php
    } else {
    $sql = "select * from search where romid != 0 && romid = $idrom";
    $query = mysql_query($sql);
    $row = mysql_fetch_array($query);
    $filenames = $row["name"];
    $files = $row["downloadurl"];
    $url = "http://mysecondaryserver.com/myfiles/";
    $files = ereg_replace(" ", "%20", $files);
    $total=$url . $files; 
    Header ( "Content-Type: application/octet-stream"); 
    Header( "Content-Disposition: attachment; filename=$filenames"); 
    readfile($total); 
    } ?>
    I used that code so that I could have a bunch of downloads on my site that are actually being downloaded off my second server... but I wanted my primary servers domain address to be shown in the download window. For some reason, since I've used this script my primary servers bandwidth has shot up to 61GB so far! That is like a $80 charge for this months hosting!!! What is going on!? Does the header script download the file to itself and THEN send it to the user downloading or something!??! help my site can't go on if this continues!!!!!
    Pixel Fuse - Signature webpage, just a spashpage.
    Flash Frogger - Frogger remake, animated/coded in Flash (incomplete/discontinued)
    Daase Art Studio - Homepage of David Daase, a Canadian landscape artist - image gallery/showcase.
    More links if I think of some...

  2.  

  3. #2
    Senior Member filburt1's Avatar
    Join Date
    Jul 2002
    Location
    Maryland, US
    Posts
    11,774
    Member #
    3
    Liked
    21 times
    Absolutely never do a SELECT *. SELECT just the columns that you need.
    filburt1, Web Design Forums.net founder
    Site of the Month contest: submit your site or vote for the winner!

  4. #3
    Senior Member joncom11's Avatar
    Join Date
    Oct 2003
    Posts
    284
    Member #
    3532
    Thanks for the tip, but that isn't what I asked...
    Pixel Fuse - Signature webpage, just a spashpage.
    Flash Frogger - Frogger remake, animated/coded in Flash (incomplete/discontinued)
    Daase Art Studio - Homepage of David Daase, a Canadian landscape artist - image gallery/showcase.
    More links if I think of some...

  5. #4
    WDF Staff smoseley's Avatar
    Join Date
    Mar 2003
    Location
    Boston, MA
    Posts
    9,729
    Member #
    819
    Liked
    205 times
    You're downloading the file from the secondary server and then reallocating it to the client. This means that you're using the bandwidth on both servers, just as you thought. The reason is that the Content-Disposition header creates a document on your primary server to be downloaded from the client. It then retrieves the file from the secondary server and reconstructs it locally for download. This is not only costly in terms of bandwidth, but slower, because the client has to wait first for the file to be reconstructed prior to beginning download.

    Try this javascript popup instead:
    PHP Code:
    <?php
    } else {
    $sql "select name, downloadurl from search where romid != 0 && romid = $idrom";
    $query mysql_query($sql);
    $row mysql_fetch_array($query);
    $filenames $row["name"];
    $files $row["downloadurl"];
    $url "http://mysecondaryserver.com/myfiles/";
    $files ereg_replace(" ""%20"$files);
    $total=$url $files
    echo 
    "<script language="javascript">window.open('$total');</script>";
    ?>
    Another way to do it would be to create an iFrame pointing to your remote site in which you show the content, like so:
    PHP Code:
    echo "<iframe width=\"100\" height=\"100\" src=\"$total\"/>"

  6. #5
    Senior Member joncom11's Avatar
    Join Date
    Oct 2003
    Posts
    284
    Member #
    3532
    Yes that would work, but the purpose of using the script I currently am is to mask the "secondaryserver.com" in the download window....
    Pixel Fuse - Signature webpage, just a spashpage.
    Flash Frogger - Frogger remake, animated/coded in Flash (incomplete/discontinued)
    Daase Art Studio - Homepage of David Daase, a Canadian landscape artist - image gallery/showcase.
    More links if I think of some...

  7. #6
    WDF Staff smoseley's Avatar
    Join Date
    Mar 2003
    Location
    Boston, MA
    Posts
    9,729
    Member #
    819
    Liked
    205 times
    And you're doing so effectively, but with the result of having the download suck up your primary server bandwidth.

    Why not create a DNS entry for your secondaryserver.com as the subdomain movies.primaryserver.com?

    That would solve your problems, I think.

  8. #7
    Senior Member joncom11's Avatar
    Join Date
    Oct 2003
    Posts
    284
    Member #
    3532
    I don't have that much control over the secondaryserver.. the secondary server is actually a server that a friend is letting me use.. all i have is ftp access to it... even if i were to make a subdomain to it.. it would still not hide the downloading address in the download dialog..
    Pixel Fuse - Signature webpage, just a spashpage.
    Flash Frogger - Frogger remake, animated/coded in Flash (incomplete/discontinued)
    Daase Art Studio - Homepage of David Daase, a Canadian landscape artist - image gallery/showcase.
    More links if I think of some...

  9. #8
    WDF Staff smoseley's Avatar
    Join Date
    Mar 2003
    Location
    Boston, MA
    Posts
    9,729
    Member #
    819
    Liked
    205 times
    If you have access to DNS on your primary server, you can create a subdomain of your primary domain and point it to the IP address of your secondary server. Therefore, instead of:

    you would have:

    EDIT: this way, the downloading address would be "images.primary.com" as you can see.
    EDIT2: temporarily, why not just link to the IP address? That way, you will at least mask out the name of the secondary domain.


Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 11:47 PM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com