NameSilo

Need a script to download to my server

Spacemail by SpaceshipSpacemail by Spaceship
Watch

bbalegere

Established Member
Impact
18
I have a major problem.
My ISP's bandwith is very small.
If I want to install some MOD for phpbb or some other package on my website, I have to download it first and upload it to my site.
Is there any way in which I can download the files directly to my server rather download to my computer and upload it again?
I heard that this can be done using a PHP script?
Can anybody give me the code or any other alternative to download files directly to my server from the internet?
PLease Help me
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
.US domains.US domains
usually cpanel nowadays come with ssh access, you can use wget if you have ssh access.
 
0
•••
How do you use ssh and wget?
I don't even know what is ssh and wget.
 
0
•••
If you want i will download the mod and upload it to your web server for a few NP$. It will save and troubles. :)
 
0
•••
Make this PHP file:

PHP:
<?php

if ($_POST['submit']) {
  $path = '/path/to/where/you/want/to/store/this/';
  $filename = $_POST['filename'];
  $file = $_POST['file'];
  exec('wget -q -O '.$path.$filename.' '.$file);
  echo 'File downloaded.';
}

?>

<form action="" method="post">
<input type="text" name="filename" /> Name to save file as<br />
<input type="text" name="file" /> File to get<br />
<input type="submit" name="submit" value="Submit" />
</form>

Make $path the path to the folder you want to save the file in. It should be like /home/username/public_html/somefolder/ and it needs a trailing slash.

(I tested the exec command with those parameters and it worked.. I'm not sure if I made the rest of the script work though. :X)
 
Last edited:
0
•••
It is not working.
Does the script work on your site?
 
0
•••
The folder where you want to save the flie should be chmodded 666.
 
0
•••
I forgot to say that. :0
 
0
•••
I chmodded it 666.
But still nothing happens.
And when I click on the folder I am taken to the root folder.
But if I chmod it back to 756 the folder opens normally.
 
0
•••
Try chmodding it to 777.
 
0
•••
replace:exec('wget*-q*-O*'.$path.$filename.'*'.$file);
with:
exec('wget '.$file);

and make sure the current folder is chmod 777.
 
0
•••
PHP:
<?php
$file = "http://blah.com/blah.ext";
ob_start();
system("wget $file 1> /tmp/cmdtemp 2>&1; cat /tmp/cmdtemp; rm /tmp/cmdtemp");
$output = ob_get_contents();
ob_end_clean();
echo str_replace(">", ">", str_replace("<", "<", $output));
?>
Give this a try instead. Make sure the folder you place this script in is 777 and alter the value of $file to be the file you wish to get.

Or you could give this script a try. A friend of mine made it a while ago.
PHP:
<?php
if ($_GET[xfer]) {
if ($_POST[from] == "") {
print "You forgot to enter a url.";
} else {
copy("$_POST[from]", "$_POST[to]");
$size = round((filesize($_POST[to])/1000000), 3);
print "transfer complete.<br>
<a><a href=\"$_POST[from]\">$_POST[from]</a><br>
<a><a href=\"$_POST[to]\">$_POST[to]</a> : $size MB";
}
} else {
print "<form action=\"$PHP_SELF?xfer=true\" method=post>
from(http://): <input name=from><br>
to(filename): <input name=to><br>
<input type=submit value=\"transload\">";
}
?>
 
0
•••
Thanks a lot for the scripts Jim.
The first script worked fine.I was able to download a file directly to my server.
But the second script did not work.
The error message I got

Warning: copy(blah.com/blah.ext): failed to open stream: No such file or directory in /home/username/public_html/forum/downto2.php on line 6

Warning: filesize(): Stat failed for target.ext (errno=2 - No such file or directory) in /home/username/public_html/forum/downto2.php on line 7
transfer complete.
 
0
•••
Yeah.. you have to enter a file that exists.. there is no blah.com/blah.ext .. :X
 
0
•••
I had entered a file that existed.
I only did not want to show it to everyone.
 
0
•••
Appraise.net
Domain Recover
DomainEasy โ€” Payment Flexibility
  • The sidebar remains visible by scrolling at a speed relative to the pageโ€™s height.
Back