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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.