PDA

View Full Version : remote download script



rinkguy
01-27-2006, 02:02 PM
I'm looking for a script that will allow me to upload files to a remote server from my local pc, as well as being able to upload downloadable files from other websites.
ie. local pc upload path would look like c:/mydocuments/file.exe
and the latter would look like http://www.website.com/downloads/file.exe

Can this be done?
If so, can someone give me a hand since I have no idea how to code.
Thanks:D

Twey
01-27-2006, 03:37 PM
http://www.tizag.com/phpT/fileupload.php

rinkguy
01-27-2006, 09:09 PM
Do you know if this will allow me to upload files to my server from web links?
I currently have ezUpload Pro 2.2 (http://www.scriptscenter.com/ezupload/) but it doesn't allow me to upload files from other websites, just from my local machine.

Twey
01-27-2006, 09:31 PM
That one's easy.
<?php
$url = "http://www.crystalinity.net/images/ginger.png";
$dir = "/home/twey/public_html/downloads/";
$rfile = fopen($url, "r");
$lfile = fopen($dir . basename($url), "w");
while(!feof($url)) fwrite($lfile, fread($rfile, 1), 1);
fclose($rfile);
fclose($lfile);
?>Requires URL file-access to be enabled on your server.

mariuspa
12-02-2006, 12:13 AM
while(!feof($rfile)) instead of while(!feof($url))

Apart of this, the code works flawlessly.

Best regards,
Marius

Twey
12-02-2006, 12:53 AM
Indeed so. A larger buffer size would probably result in increased performance too:
<?php
define('BUFSIZ', 4095);
$url = 'http://www.twey.co.uk/images/ginger.png';
$dir = '/home/twey/public_html/downloads/';
$rfile = fopen($url, 'r');
$lfile = fopen($dir . basename($url), 'w');
while(!feof($rfile))
fwrite($lfile, fread($rfile, BUFSIZ), BUFSIZ);
fclose($rfile);
fclose($lfile);
?>