Downloading files
Moderator: General Moderators
Downloading files
OK, I'm having to Use URLs from a file and make my server download these files. For some reason it won't do it, but when I copy and paste the URLs they work in my browser. here is an example
torrent link to copyrighted content removed
do you think the fread() needs me to encode the URL in some way? I'm also using file_get_contents as a backup and still nothing.
torrent link to copyrighted content removed
do you think the fread() needs me to encode the URL in some way? I'm also using file_get_contents as a backup and still nothing.
- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact:
- Maugrim_The_Reaper
- DevNet Master
- Posts: 2704
- Joined: Tue Nov 02, 2004 5:43 am
- Location: Ireland
Jcart | Please use
Jcart | Please use
Code: Select all
andCode: Select all
tags when posting code[/color]Code: Select all
//downloading functions
function getFileContents($fullPath){
$path = $fullPath;
if( doesFileExist($path)){
$return = file_get_contents($path);
return $return;
}
}
function downloadFile($URL,$bytes='128'){
if ( $fp = fopen($httpurl, "r") ){
$stream = "";
if ($fp) {
while( !feof( $fp ) ) {
$stream .= fread($fp, $bytes);
}
}
fclose($fp);
}else{
$stream = NULL;
}
return $stream;
}
///end library
$Contents = downloadFile($data['URL']);
if($Contents == NULL){
$Contents = getFileContents($data['URL']);
}
if($Contents == NULL){
$Contents = getFileContents(rawurldecode($data['URL']));
}
if($Contents != NULL){
write_file($Temp_path,$Contents);
}Code: Select all
andCode: Select all
tags when posting code[/color]....yeah I do know that. that's not the point. I'm just trying to download the file itself. to the server, I'm mainly wondering if it needs to be encoded for URL, IE spaces must be %20 or something to that effect.Maugrim_The_Reaper wrote:Just to be certain - you're aware this is a torrent file? Requires a torrent client to download the file it represents. Downloading the url will usually net you a 20KB or so file used by a torrent client.
If i'm not mistaken there is an option to indicate which chunk of a document/page you really want to recieve... That way you could pause/resume downloads (if the server is capable of this functionality).. Much nicer than having to download the complete file again if your connection dies after 500mb of a 600mb iso...
- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
Code: Select all
$file = 'http://example.com/test.torrent';
$data = file_get_contents($file);
$h=fopen('downloads/'.basename($file),'w');
fwrite($h,$data);
fclose($h);don't worry I got it.
but the clerify I am talking about downloading. Although it's not downloading from to my computer it's downloading from a host to my server which is still "downloading" also I just wanted the torrent file not the file it points to.
in the end my system has been completed with version 1. Pretty much it was a system to add torrents to itself on it's own. it cam out pretty well (http://www.anivision.us)
but the clerify I am talking about downloading. Although it's not downloading from to my computer it's downloading from a host to my server which is still "downloading" also I just wanted the torrent file not the file it points to.
in the end my system has been completed with version 1. Pretty much it was a system to add torrents to itself on it's own. it cam out pretty well (http://www.anivision.us)
- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
- Ambush Commander
- DevNet Master
- Posts: 3698
- Joined: Mon Oct 25, 2004 9:29 pm
- Location: New Jersey, US