Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Geek Culture / download files TO an online server?

Author
Message
Phaelax
DBPro Master
22
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 28th Sep 2010 02:02
I'm wondering if there's a way to download a file but rather than have it downloaded to my computer I want it sent directly to a folder on my web server. A browser plugin would be great but I'd be just fine running a script on my site that I can use provided the file's http path which would download it there.

Would existing download scripts allow file uploads from other online servers or would that cause a security violation? Obviously, the page running the script would be protected and not open to the public.


"Any sufficiently advanced technology is indistinguishable from magic" ~ Arthur C. Clarke
Jeku
Moderator
21
Years of Service
User Offline
Joined: 4th Jul 2003
Location: Vancouver, British Columbia, Canada
Posted: 28th Sep 2010 02:18
You can look into using webdav or FTP, but that's about as much as I know. I have done this before with FTP, but soon switched to using Amazon AWS.


Senior Web Developer - Nokia
Phaelax
DBPro Master
22
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 28th Sep 2010 02:27 Edited at: 28th Sep 2010 02:27
It looks like I can do it with PHP, I'm testing a script now. If it works I'll make a fancy front-end for the script.




"Any sufficiently advanced technology is indistinguishable from magic" ~ Arthur C. Clarke
The Wilderbeast
19
Years of Service
User Offline
Joined: 14th Nov 2005
Location: UK
Posted: 28th Sep 2010 09:31
SSH and WGET are what you want.

dab
20
Years of Service
User Offline
Joined: 22nd Sep 2004
Location: Your Temp Folder!
Posted: 28th Sep 2010 18:51
Quote: "SSH and WGET are what you want."

If the host allows SSH, which most hosts don't. But if it does just cd to the folder you want to place the file and wget http://website.tld/file.zip


You could use this simple 1-liner script as well


<?php
file_put_contents( 'file.zip', file_get_contents( 'http://website.tld/file.zip' ) );
?>

Also make sure you validate all files being downloaded (IE: PHP, Binary) so people aren't malicious (If your download script is public).

The Wilderbeast
19
Years of Service
User Offline
Joined: 14th Nov 2005
Location: UK
Posted: 28th Sep 2010 21:32
Quote: "If the host allows SSH, which most hosts don't. But if it does just cd to the folder you want to place the file and wget http://website.tld/file.zip"


I guess it all depends on whether he is on VPS or Dedicated.

Phaelax
DBPro Master
22
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 28th Sep 2010 22:52
I used the script I posted above, and it seemed to create the file on the other server. However, when I attempt to download it to my PC through FTP it fails every time. Maybe it didn't finish transferring the file yet? Also, I didn't have the binary mode in the script either, could cause issues perhaps.

Any method for getting the progress of the transfer? That would be a major help.


"Any sufficiently advanced technology is indistinguishable from magic" ~ Arthur C. Clarke
bitJericho
22
Years of Service
User Offline
Joined: 9th Oct 2002
Location: United States
Posted: 30th Sep 2010 13:49
All of this can be done via ftp. Why are you reinventing the wheel

Login to post a reply

Server time is: 2025-05-23 06:10:54
Your offset time is: 2025-05-23 06:10:54