Server to server file transfer script!

Post your scripts here.

<b>Note:</b>The scripts must be your own, and please read the "Important: Read before you post" thread inside this category before participating here.
Locked
freak127
Posts: 17
Joined: Sun Nov 27, 2005 10:41 am

Server to server file transfer script!

Post by freak127 »

Simply copy this into a PHP file and save it onto your website:

Code: Select all

<?
if ($_GET[act])
{
   if ($_POST[from] == "")
      {
         print "You need to enter the URL of the file.";
      }
   else
   {
      copy("$_POST[from]", "files/$_POST[to]");
      $size = round((filesize("files/$_POST[to]")/1000000), 3);
      print "Success! The file <a><a href=\"$_POST[from]\">$_POST[from]</a> is now stored on our server. You can view it here:

      <a><a href=\"files/$_POST[to]\">$_POST[to]</a> $size MB";
   }
}
else
{
   print "<form action=\"$PHP_SELF?act=transload\" method=post>
   URL of file: <input name=from>

   New filename: <input name=to>

   <input type=submit value=\"Transload file!\">";
}
?>
When you have done that, make a directory in the same place as this script called 'files' and CHMOD it to 0777. When you have done that, it should work fine ;) .
If you have any questions or anything then just let me know :) .


kaos_frack
Posts: 504
Joined: Sat May 07, 2005 8:03 am
Contact:

Post by kaos_frack »

so you use copy() function
does it work for files on other servers?

i used this script for the same purpose

<?php
// $url and $fname come after a form submission
if (isset($url) && isset($fname))
{
$fhandle = fopen($url, "rb");
$fcontents = "";
while (!feof($fhandle)) $fcontents .= fread($fhandle, 1024);
fclose($fhandle);
touch($fname);
$fhandle = fopen($fname, "wb");
fwrite($fhandle, $fcontents);
fclose($fhandle);
echo "done...";
}
?>
Locked