meclive wrote:Im wanting to create a page where i enter a url (e.g. somesite.com/file.zip) and it downloads the file to a folder on my site. I have tried a number of scripts out that say they do this (e.g. directdl php) but i cannot get them to work. Can this be done with php? do i need to use cURL? I dont think it would be that hard for any of you experts out there to do but im stumped! so any help would be appreciated! thanks.
Its not always that easy, you'll have to try and open the file, read its contents. Once that is done then you'll need too create a file on your site and then write the contents of the old file too your new one.
SOmething like this may work (Untested):
<?php
if (isset($_GET['File']) == true){
$ToDir = './'; ## Where the files will be made on your server.
$FileContents = implode('', file($_GET['File']));
$FileNameP = explode('/', $_GET['File']);
$FileName = $FileNameP[count($FileNameP) - 1];
if (($FileContents != '') && (fopen($ToDir . $FileName, 'w') != 0)){
$File = fopen($ToDir . $FileName, 'w');
$Write = fwrite($File, $FileContents);
if ($Write != 0){
echo 'The file ' . $ToDir . $FileName . ' was successfully created!';
fclose($File);
}
else{
echo 'There was an error; the file could not be created.';
}
}
}
?>
Cheers,
Ryan Jones