...

View Full Version : Remote Upload Code Upgrade



PeeItchPee
11-19-2010, 10:48 PM
Hello,

I found this code before and I have been using it for some time.

it is for downloading/uploading files to my server remotely

however every link I want to upload/download to my server, I have to edit the php file and add the URL then open the PHP file.

is there any way to make it easier?

just like in Rapidshare's remote upload, you copy and paste multiple links, paste them in a text box and then click "Start" and it starts downloading all of the files one by one to the server.

here's the code:



<?php
define('BUFSIZ', 4095);
$url = 'LINK HERE';
$rfile = fopen($url, 'r');
$lfile = fopen(basename($url), 'w');
while(!feof($rfile))
fwrite($lfile, fread($rfile, BUFSIZ), BUFSIZ);
fclose($rfile);
fclose($lfile);
?>

DrDOS
11-19-2010, 11:07 PM
It doesn't look like it would be very difficult to add a form input to put the URL into the code. Looks like a kind of fun little project to me. Make it so that if the form isn't submitted the code doesn't run, then when you submit the URL it does it's thing.

PeeItchPee
11-20-2010, 04:29 PM
It doesn't look like it would be very difficult to add a form input to put the URL into the code. Looks like a kind of fun little project to me. Make it so that if the form isn't submitted the code doesn't run, then when you submit the URL it does it's thing.


Yep :D:thumbsup:

PeeItchPee
11-21-2010, 05:12 PM
Hope you didn't forget =[

DrDOS
11-21-2010, 08:13 PM
Hope you didn't forget =[I didn't think you wanted someone to do it, just wanted an idea that would work. I don't have enough of the code to actually make what you have there work, I need to have a look at all the code that makes that function to really write something for it.

PeeItchPee
11-22-2010, 07:52 AM
I didn't think you wanted someone to do it, just wanted an idea that would work. I don't have enough of the code to actually make what you have there work, I need to have a look at all the code that makes that function to really write something for it.

lol yeah I wanted someone to do it, sorry I wasn't clear, and I have no clue about PHP codes :eek: lololol

sorry maybe I didn't understand you but that's all of the code mate, nothing else.

dominicdinada
11-22-2010, 09:29 AM
there is rentacoder, getafreelancer, etc websites. or there are thousands of free online resources to do just what you are looking for

DrDOS
11-22-2010, 05:05 PM
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"

"http://www.w3.org/TR/html4/loose.dtd">

<html>

<head>

<meta content="text/html; charset=utf-8" http-equiv="content-type">

<script type="text/javascript">

//Alerts to errors.

window.onerror=function(msg, url, linenumber){var logerror='Error message: ' + msg + '. Url: ' + url + 'Line Number: ' + linenumber;alert(logerror);return false}

</script>

<title>Upload Form</title>

<style type="text/css">

body

{

margin: 0 auto;

width:900px;

font-family:serif

}

#upload_box

{

background-color: LightBlue;

border:1px solid Black;

padding:20px;

margin-top:40px;

width: 50%;

}

</style>

<?php

if (isset($_POST['myupload']))

{

define('BUFSIZ', 4095);

$url = $_POST['upload'];

$rfile = fopen($url, 'r');

$lfile = fopen(basename($url), 'wb');

while(!feof($rfile))

fwrite($lfile, fread($rfile, BUFSIZ), BUFSIZ);

fclose($rfile);

fclose($lfile);

}

?>

<script type="text/javascript"></script>

</head>

<body>

<div id="upload_box">

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

<input type="text" name="upload">

<input type="submit" name="myupload" value="Upload File">

</form>

</div>

</body>

</html>
Well, I coded it anyway, looks like a useful little item, just put it in the folders you want to upload the files too. Only does one file at a time now, I will probably revise it to do a list of files later.

DrDOS
11-22-2010, 09:20 PM
Added a textarea and a loop to upload multiple files. Quick and dirty but tested. Just make a list of the URLs and paste it in.
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"

"http://www.w3.org/TR/html4/loose.dtd">

<html>

<head>

<meta content="text/html; charset=utf-8" http-equiv="content-type">

<script type="text/javascript">

//Alerts to errors.

window.onerror=function(msg, url, linenumber){var logerror='Error message: ' + msg + '. Url: ' + url + 'Line Number: ' + linenumber;alert(logerror);return false}

</script>

<title>Upload Form</title>

<style type="text/css">

body

{

margin: 0 auto;

width:864px;

font-family:serif

}

#upload_box

{

background-color: LightBlue;

border:1px solid Black;

padding:20px;

margin-top:40px;

}

</style>

<?php

if (isset($_POST['myupload']))

{

$links_list = $_POST['upload'];

$incr = 0;

$links = explode("\r\n",$links_list);

define('BUFSIZ', 4095);

for ( $incr == 0 ; $incr < count($links) ; $incr++ )

{

$url = $links[$incr];

$rfile = fopen($url, 'r');

$lfile = fopen(basename($url), 'wb');

while(!feof($rfile))

fwrite($lfile, fread($rfile, BUFSIZ), BUFSIZ);

fclose($rfile);

fclose($lfile);

}

}

?>

<script type="text/javascript"></script>

</head>

<body>

<div id="upload_box">

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

<textarea name="upload" cols=80 rows=20></textarea>

<input type="submit" name="myupload" value="Upload Files">

</form>

</div>

</body>

</html>

PeeItchPee
11-23-2010, 04:59 PM
For some reason, on both of your codes..
the downloads are really slow and I get "Internal Server Error" :(

but with the code i have, very fast with no errors. :confused:

DrDOS
11-23-2010, 05:23 PM
I just tried it on remote ( non-localhost ) server and it worked fine. You may have a permissions problem, or if you have a Windows server you may have to change the syntax for the explode characters, although I wrote it to work on Windows too. Also, I did not change the code you were using before, just added code to let you put the URL in easily.

PS: Just added username/password fields to give some security. Change them to whatever you want.

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"

"http://www.w3.org/TR/html4/loose.dtd">

<html>

<head>

<meta content="text/html; charset=utf-8" http-equiv="content-type">

<script type="text/javascript">

//Alerts to errors.

window.onerror=function(msg, url, linenumber){var logerror='Error message: ' + msg + '. Url: ' + url + 'Line Number: ' + linenumber;alert(logerror);return false}

</script>

<title>Remote File Transfer</title>

<style type="text/css">

body

{

margin: 0 auto;

width:900px;

font-family:serif

}

#upload_box

{

background-color: LightBlue;

border:1px solid Black;

margin-top:40px;

}

</style>

<?php

if (isset($_POST['myupload']))

{

$user_name = $_POST['user'];

$pass_word = $_POST['pass'];

if ( $user_name=='justme' && $pass_word=='myself' )

{

$links_list = $_POST['upload'];

$incr = 0;

$links = explode("\r\n",$links_list);

define('BUFSIZ', 4095);

for ( $incr == 0 ; $incr < count($links) ; $incr++ )

{

$url = $links[$incr];

$rfile = fopen($url, 'r');

$lfile = fopen(basename($url), 'wb');

while(!feof($rfile))

fwrite($lfile, fread($rfile, BUFSIZ), BUFSIZ);

fclose($rfile);

fclose($lfile);

}

}

}

?>

<script type="text/javascript"></script>

</head>

<body>

<fieldset id="upload_box">

<label>Remote File Transfer Form</label>

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

<input type="text" name="user" Value="Your Username">

<input type="text" name="pass" Value="Your Password"><br>

<textarea name="upload" cols=80 rows=20></textarea>

<input type="submit" name="myupload" value="Transfer Files">

</form>

</fieldset>

</body>

</html>

mAlam
07-17-2012, 12:37 PM
I just tried it on remote ( non-localhost ) server and it worked fine. You may have a permissions problem, or if you have a Windows server you may have to change the syntax for the explode characters, although I wrote it to work on Windows too. Also, I did not change the code you were using before, just added code to let you put the URL in easily.

PS: Just added username/password fields to give some security. Change them to whatever you want.

skipped to make the post smaller...

hi, dear sir, i have used your code.. but i m facing some problem..

your code works only for direct link files like:

http://www.example.com/sample.avi

but if the source/url is a big and not direct link file then it will not work.. and create a very large error log file :(

for example; following is an direct video link for youtube:

http://r13.par08s04.c.youtube.com/videoplayback?upn=EdIhJvNud8w&sparams=cp%2Cid%2Cip%2Cipbits%2Citag%2Cratebypass%2Csource%2Cupn%2Cexpire&fexp=916004%2C910102%2C913602%2C907217%2C907335%2C921602%2C919306%2C922600%2C919316%2C919804%2C92070 4%2C924500%2C906831%2C924700%2C913542%2C913547%2C919324%2C920706%2C924402%2C907344%2C912706%2C902518&ms=nxu&itag=22&ipbits=8&signature=01F92402966D1DEEC4FD40C75BD871B6B168415C.4616D705C13FD9E6C7B55AB50CCAC52A6B6D2FC5&sver=3&mt=1342524127&ratebypass=yes&source=youtube&expire=1342548842&key=yt1&ip=180.211.196.203&cp=U0hTR1VPVl9JTENOM19NSVpJOnZrZElkY2d5MTU0&id=a8910422c69c2ecc&redirect_counter=1&cms_redirect=yes&st=nx&ir=1

i use internet download manager and it generate that direct link form most of the video sites, and i need to download videos/file form those link by using your php scripts..

but it don't work for that kind of link..

i even try to change :
from:

$lfile = fopen(basename($url), 'wb');
to:

$lfile = fopen('yt.flv', 'wb');

but still it don't work..

so, if you can give me an idea/solution then it would be great :)

please sir, leave a reply asap

best regards



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum