Zubrag.com
September 19, 2018, 11:03:44 AM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
 
   Home   Help Search Login Register  
Pages: [1] 2
  Print  
Author Topic: PHP Download / Upload of a remote file  (Read 76198 times)
Monoxide
Newbie
*
Posts: 4


« on: August 09, 2007, 10:47:34 AM »

I'v searched google and many other sites and I am clueless....

I am looking for something like torrentflux but for remote http or ftp downloads

best I can explain it is have my website download a file from another website without me having to manually download the file from that site then upload it to my host.

is there a way? Huh is there a modified upload page that will download a remote link to my host?

Logged
zubrag
Administrator
Hero Member
*****
Posts: 788


WWW
« Reply #1 on: August 10, 2007, 10:13:43 AM »

Hi. Should it work as described below?

- you open page on your server in browser, it prompts for remote file path (url)
- you press a button, script downloads that file from remote host and places it on your server?

If so, save following as php file (ex: download.php), update $destination_folder below, open it in browser, and provide file name.

<form method="post">
<input name="url" size="50" />
<input name="submit" type="submit" />
</form>
<?php

// maximum execution time in seconds
set_time_limit (24 * 60 * 60);

if (!isset($_POST['submit'])) die();

// folder to save downloaded files to. must end with slash
$destination_folder = 'mydownloads/';

$url = $_POST['url'];
$newfname = $destination_folder . basename($url);

$file = fopen ($url, "rb");
if ($file) {
  $newf = fopen ($newfname, "wb");

  if ($newf)
  while(!feof($file)) {
    fwrite($newf, fread($file, 1024 * 8 ), 1024 * 8 );
  }
}

if ($file) {
  fclose($file);
}

if ($newf) {
  fclose($newf);
}

?>
Sample values for ftp and http
ftp://username:password@example.com/path/to/file.png
ftp://example.com/path/to/file.png
http://www.example.com/path/to/file.png
Logged
Monoxide
Newbie
*
Posts: 4


« Reply #2 on: August 10, 2007, 02:49:42 PM »

Warning: fopen(mydownloads/*******.md5) [function.fopen]: failed to open stream: Permission denied in /home/monoxide/public_html/downloader.php on line 18

I had created the mydownloads folder because it seemed like a good name,
Code:
if ($newf) {
  fclose($newf);
seems to be the 18th line if I counted right

if this works do you have an banner I could link your site from mine.
Logged
zubrag
Administrator
Hero Member
*****
Posts: 788


WWW
« Reply #3 on: August 13, 2007, 04:15:53 AM »

Looks like you'll have to fix permissions on the "mydownloads" folder. Need to allow script to write to that folder. I believe 777 should work, but try if 755 or 775 work first.

We do not have a banner. But you could link using the code below (usual link).
<a href="http://www.zubrag.com" title="Free php scripts">Free php scripts</a>
Logged
Monoxide
Newbie
*
Posts: 4


« Reply #4 on: August 13, 2007, 12:25:11 PM »

kool small files worked perfect! Grin

now I get this error
Code:
Fatal error: Maximum execution time of 30 seconds exceeded in /home/monoxide/public_html/down.php on line 22

it is a 4.2gb file
also do I need to keep the script open in my window while it works or when I exit it from my browser it will just continue to download the file given Huh
Logged
zubrag
Administrator
Hero Member
*****
Posts: 788


WWW
« Reply #5 on: August 13, 2007, 04:09:32 PM »

I updated the script above. Added set_time_limit (24 * 60 * 60);    Now it should not produce "Maximum execution time...".

do I need to keep the script open in my window while it works or when I exit it from my browser it will just continue to download the file given
I think it depends on how server is setup. Some servers check if client is still connected. Try on 5-10Mb files to find out (close your browser somewhere in the middle and check later if whole file was downloaded correctly).

BTW: this script does not support "resume downloads" (will have to start from the beginning if disconnected), so it is not good for such big files.
Logged
Monoxide
Newbie
*
Posts: 4


« Reply #6 on: August 13, 2007, 08:11:36 PM »

kool, will do like I said works great for small files Cheesy

I have even looked into SST and it was a crock lol

you dont know how much this has helped me, thanks Cool
Logged
billigee
Newbie
*
Posts: 1


« Reply #7 on: April 19, 2009, 04:41:54 AM »

i am having trouble with this script plz help me i got the error

Warning: set_time_limit() has been disabled for security reasons in /www/xxxxxxxx.com/b/i/l/username/htdocs/download.php on line 8

Warning: fopen() [function.fopen]: URL file-access is disabled in the server configuration in /www/xxxxxxxx.com/b/i/l/username/htdocs/download.php on line 18

Warning: fopen(http://xxxxx/filename.mkv.003) [function.fopen]: failed to open stream: no suitable wrapper could be found in /www/xxxxxxxx.com/b/i/l/username/htdocs/download.php on line 18

Notice: Undefined variable: newf in /www/xxxxxxxx.com/b/i/l/username/htdocs/download.php on line 32
Logged
recoding
Global Moderator
Jr. Member
*****
Posts: 71


WWW
« Reply #8 on: June 04, 2009, 02:53:32 AM »

This problem is created because your host has disabled some functions for security reasons, I would recommend speaking to your host if you really need this script, or trying another host.

-Dan!
Logged

brygee
Newbie
*
Posts: 4


« Reply #9 on: June 09, 2009, 07:58:07 AM »

I dont know if anyone has come across this script but it does as you request and loads more!!  You can also designate which folder you want to 'crossload' to your server http://www.webfilebrowser.org/

"Web File Browser is a simple open-source file browser written in PHP (1 single file) that allows users to create, delete, edit, copy, rename, move and upload files and directories thru a light, full-text, web-based interface "

hope that helps
Logged
sesese
Newbie
*
Posts: 1


« Reply #10 on: April 12, 2010, 06:59:40 PM »

ok, the script worked!
but i have a cuestion..

how to copy multiple files in my host??

http:domain.com/file1.rar
http:domain.com/file2.rar

SEND!

SUCCESS! xD
Logged
Kimball342
Newbie
*
Posts: 11


« Reply #11 on: August 11, 2010, 12:23:56 AM »

I am totally unable to understand whats written here, actually i am not the person of this field, anyhow may be it is interesting for anyone.
Logged
zYx
Newbie
*
Posts: 1


« Reply #12 on: November 03, 2010, 07:28:10 PM »

Hey guys.

I found this topic on the net as I am looking for something similar.

I want to save an image from www to my ftp server, every say 24 hours. So it means that when the same image file is being downloaded all the time, it would have to give it a different name, such as image.1.jpg, image.2.jpg etc..

How do I do that?

I can run the script by using CronTab in my cPanel. All I need is a download.php file that will be executed by crontab :]

Thanks in advance!
Logged
php2011
Newbie
*
Posts: 2


« Reply #13 on: December 25, 2010, 03:31:46 AM »

Hi! PHPcPanel is an opensource tool for automatically manage cPanel without requiring

manually login.


http://www.ushops.net/phpcpanel/

It can automatically manage your cpane for creating FTP and mysql accounts. If you are a web master, you could easily combine

PHPcPanel to your projects. Enjoy!
Features

(1) Automatically login your cpanel without goto cpanel;

(2) Create/Edit ftp account by using PHP function;

(3) Create/Edit mysql account by using PHP function;

(4) It is easily combine PHPcPanel to your own php project to manage your cPanel..

Demo >>

Download Latest Version

Download Latest PHPcPanel  Package

Logged
Pages: [1] 2
  Print  
 
Jump to:  

Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC