simple script request

Associate
Joined
24 Sep 2006
Posts
1,267
Hi,
I was hoping someone could help with a simple FTP upload script.
I am in charge of a couple of gaming servers which sometimes crash and need to be restarted.
This is done by uploading a file called "restart" (no extension) to the server/s FTP.
So, I would like a simple web page (php?) that I can tell my server admins of, where they can just click a link/button to upload this specific file to a specified ftp.
I guess this could be done quite easily for some of you clever chaps, so thanks in advanced if this is so!
If not, np ;)
 
If you literally just need to upload a file just do a google for php upload, as its very simple to do using php. Only problem I can see is if the file needs to be uploaded outside the public_html folder on the destination server - not sure that you could do that using a web based upload - sure someone will correct me if I'm wrong :)
 
Hi,
I had a look around for existing scripts and found this:
Code:
<?php
$ftp_server = "####
$ftp_user_name = "####";
$ftp_user_pass = "####";
$source_file = "/public_html/restart";
if (!file_exists($source_file)) { 
die ('the source file does not exist!'); 
}
$destination_file = "file.ext";

echo $conn_id = ftp_connect($ftp_server); 

echo $login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass); 

if ((!$conn_id) || (!$login_result)) { 
echo "FTP connection has failed!";
echo "Attempted to connect to $ftp_server for user $ftp_user_name"; 
exit; 
} else {
echo "Connected to $ftp_server, for user $ftp_user_name";
}

echo $upload = ftp_put($conn_id, $destination_file, $source_file, FTP_BINARY); 

if (!$upload) { 
echo "FTP upload has failed!";
} else {
echo "Uploaded $source_file to $ftp_server as $destination_file";
}

// close the FTP stream 
ftp_close($conn_id);
My idea was to use this to transfer the needed file from my ftp to the game server's ftp.
However, this error appears:
Code:
Warning: file_exists() [function.file-exists]: open_basedir restriction in effect. File(/public_html/restart) is not within the allowed path(s): (/home/johnyccc:/usr/lib/php:/usr/local/lib/php:/tmp) in /home/johnyccc/public_html/test.php on line 6
the source file does not exist!

Thanks for any help!
 
Have you got a file called file.ext on the remote server, as iirc ftp_put() overwrites the desination file

I also think (and I may be wrong) that you need to specify two actual files for the local and destination files.
 
Last edited:
Back
Top Bottom