What\’s Up

Transloading – Copying Files From Server to Server

with 5 comments

Let me start off the blog with a very good application. Before I got much used to PHP, I was wondering much about transloading which is nothing but copying a file from one server to another. At that time I couldn't find much about it and I really became mad finding how to do that. Well, there is no need for you to become mad 🙂 , here is the code:

<?

if ($transload)

{

if ($_POST[sourceurl] == "")

{

print "Please enter the source URL";

}

else

{

$sourceurl = $_POST[sourceurl];

$newname = $_POST[newname];

copy("$sourceurl", "files/$newname");

$newsize = round((filesize("files/$newname")/1000000), 3);

echo "The file $sourceurl has been successfully transloaded here:

<a href=files/$newname>$newname</a> - $newsize MB";

}

}

else

{

?>

<form action="" method="post">

Source URL: <input type="text" name="sourceurl"><br>

Destination filename: <input type="text" name="newname"><br>

<input type="submit" name="transload" value="Transload">

<?

}

?>

The above code is very useful when files are needed to be transferred while changing hosting provider as it is very fast compared to usual method of downloading and then uploading. 

Advertisements

Written by lokesh

May 13, 2006 at 4:08 pm

Posted in PHP

5 Responses

Subscribe to comments with RSS.

  1. Just forgot to mention about chmodding…you need to chmod the files folder to 777 only then your file will be copied successfully.

    lokesh

    May 14, 2006 at 5:11 am

  2. Ok I cant believe its that fricking easy!

    Jake

    September 26, 2006 at 1:32 am

  3. hey there, there is an error in ur code man.
    u didnt speify the end of the form, ie, above the second php code fragment.
    Also, inform the users to specify he form action attribute while deploying ur script.

    Thanks !

    bharath

    August 24, 2007 at 10:05 am

  4. oops, cant include tags in comment!

    bharath

    August 24, 2007 at 10:21 am

  5. I can’t use this code. I copy the code into a PHP (and a HTML) file, then upload to the host. I run the file, put the URL of the file I need to transload, put the new file name, then press Transload, and nothing happen! Please help!

    Esente

    August 24, 2007 at 6:55 pm


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: