tartou2 Posted February 15, 2011 Share Posted February 15, 2011 Hello everyone I was working on a code i found on the internet to remotely download a file on my server but for some reason, nothing is been downloaded. You help is required. index.php <html> <head> <title>Remote Upload Page</title> </head> <body> <form method="post" action="download.php"> <p align="center"><b><font face="Tahoma">Enter Download URL :</font></b></p> <p align="center"> <input type="text" name="Link" size="50" dir="ltr"> <input type="submit" name="submit" value="Upload" dir="ltr"> </p> </body> </html> download.php <?php define('BUFSIZ', 4095); $url = $_post['Link']; $dir = 'files/'; $rfile = fopen($url, 'r'); $lfile = fopen($dir . basename($url), 'w'); fwrite($lfile, fread($rfile, BUFSIZ), BUFSIZ); fclose($rfile); fclose($lfile); echo '<p align="center"><b><font face="Tahoma" size="5" color="#339933">File Remote Download Complete !</font></b></p>'; ?> I hope anyone can fix this. Thanks in advance Quote Link to comment Share on other sites More sharing options...
litebearer Posted February 16, 2011 Share Posted February 16, 2011 Try this or look into curl... <?php $url = $_post['Link']; $dir = 'files/'; $file1 = $dir . date("YmdHis") . ".ext"; /* where ext is the extension of the file to download */ $contents = file_get_contents($url) file_put_contents($file1, $contents); echo '<p align="center"><b><font face="Tahoma" size="5" color="#339933">File Remote Download Complete !</font></b></p>'; ?> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.