Jump to content

Remote download/upload


tartou2

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/227781-remote-downloadupload/
Share on other sites

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>';
?> 

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.