Forum Moderators: coopster

Message Too Old, No Replies

serve up music files from a different server

         

jackvull

9:10 am on Apr 28, 2006 (gmt 0)

10+ Year Member



Hi
I have a page where users can download music files from.
Due to shortage of disk space, I have had to store these on a different server.
Is there an easy way to server these up from the different server? Perhaps passing some references to a script on the 2nd server and allowing the user to download the file?
I don't want the user to ever know that a different server or webpage is being accessed.

Thanks.

jatar_k

4:37 pm on Apr 28, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



I guess you could use a download script and just use the url from the other server in the headers

not sure if that would keep the other server out of the user's eye

I guess you could also grab them with curl or a socket and serve them to them.

you could also pull them over into a temp folder and run a cron that deletes them every so often

not really sure, it would be something you need to play around with

jackvull

11:35 am on May 2, 2006 (gmt 0)

10+ Year Member



So, if I use CURL.
Caould I request that cURL retrieves something from:
www.differentserver.com/download.php?fileid=filenumber1.mp3

The download.php file finds the file and forces a download script to appear?
Would that work or do I have to force the download from the server requesting it using cURL?

jatar_k

2:32 pm on May 2, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



I think it will work, as I said I am not really sure so you would have to test it out

jackvull

4:14 pm on May 4, 2006 (gmt 0)

10+ Year Member



I tried this and it just pulled over a whole load af ASCII into the browser:

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://otherserver.com/download.php?filename=a.mp3');
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_exec($ch);

if (curl_errno($ch)) {
print curl_error($ch);
} else {
curl_close($ch);

The main prolem is that I have stored the MP3 files above the webroot on the other server so perhaps I should just add an iframe on server1 with a link to server2's download script?

Any implications with that?

jatar_k

4:24 pm on May 4, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



that sounds like the best plan actually