Jump to content

[SOLVED] Download and upload to my site


newbtophp

Recommended Posts

I have many files hosted at www.hotfile.com. I want to have a form on my site where I input the hotfile.com download links, and then once submit is clicked the files from www.hotfile.com are uploaded to my site.

 

PS: The reason I want to do is, I dont want the download links to be dead, and I can't be downloading the files to my computer since, I have a slow connection, uploading the files to my site will make sure thiers never a dead link.

 

Hotfile download links look like this:

 

http://hotfile.com/dl/6270357/13cd015/phpdblesson01introduction.rar.html

 

If I break the hotfile.com download url down;

 

This always stays the same:

http://hotfile.com/dl/

 

This always changes:

/6270357/13cd015/

 

This is the filename (always changes):

/phpdblesson01introduction.

 

This is the file format (download links can only be .rar.html or .zip.html):

.rar.html

 

Im guessing this would be done by cURL and the FTP format: [ftp=ftp://user:[email protected]]ftp://user:[email protected][/ftp]

 

Can anyone give me some help, so I can work in to the code.

 

Thanks alot.

 

Link to comment
https://forums.phpfreaks.com/topic/163235-solved-download-and-upload-to-my-site/
Share on other sites

Heres an update:

 

chmod 777 folder: files, input the download urls in the $urls array and the files will be stored in /files.

 

However the trouble is it aint storing the file/rar, its downloading the html of the download page, bypassing the awaiting limit is the issue.  :-\

 

<?php

$urls=array(
'http://hotfile.com/dl/6270357/13cd015/phpdblesson01introduction.rar.html');

$save_to='/home/dechost/public_html/files/';

$mh = curl_multi_init();
foreach ($urls as $i => $url) {
    $g=$save_to.basename($url);
    if(!is_file($g)){
        $conn[$i]=curl_init($url);
        $fp[$i]=fopen ($g, "w");
        curl_setopt ($conn[$i], CURLOPT_FILE, $fp[$i]);
        curl_setopt ($conn[$i], CURLOPT_HEADER ,0);
        curl_setopt($conn[$i],CURLOPT_CONNECTTIMEOUT,60);
        curl_multi_add_handle ($mh,$conn[$i]);
    }
}
do {
    $n=curl_multi_exec($mh,$active);
}
while ($active);
foreach ($urls as $i => $url) {
    curl_multi_remove_handle($mh,$conn[$i]);
    curl_close($conn[$i]);
    fclose ($fp[$i]);
}
curl_multi_close($mh);
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.