phani_kosaraju Posted January 2, 2009 Share Posted January 2, 2009 Hi, I have 2 servers, I had a script in 1st server. That script functionality is uploading the files to the server. Now my requirement is by using the same script i want to upload the files to the 2nd server. I dont want to install the same script in 2nd server. Can we do this? if yes, please tell me the procedure. If you need any clarification please ping me at gtalk ---- phani@vanquishtechnologies.com yahoo --- phani_kosaraju@yahoo.co.uk Thanks in advance. Phani Krishna K. Quote Link to comment Share on other sites More sharing options...
DarkSuperHero Posted January 2, 2009 Share Posted January 2, 2009 try using a script that logs in using an ftp account for the second server.... theres ftp functions built into php... http://us.php.net/ftp_put Quote Link to comment Share on other sites More sharing options...
DarkWater Posted January 2, 2009 Share Posted January 2, 2009 The FTP functions will get the job done, but they're probably not as efficient as just putting the script on the other server. Any particular reason why you can't? Quote Link to comment Share on other sites More sharing options...
hobeau Posted January 2, 2009 Share Posted January 2, 2009 Hi phani_kosaraju, If you check out these two urls http://www.solutionbot.com/2008/12/27/secure-file-upload/ and http://www.solutionbot.com/2009/01/02/php-ftp-class/ this should at least get you started. The first url is a secure file uploading class that allows you to upload files safely to your server. Security is a HUGE issue here as you will read in the article since any hacker could upload a malicious .php file that would allow them to get a list of all of the files and read all the files in your directory and then read all the source code. This is just one possibility, but believe me there are many many more negative outcomes from this if you do not secure your code. The second one is an FTP class which is a wrapper class for ftp functions in PHP. What I'm thinking you could do is the following: <?php if ($_SERVER['REQUEST_METHOD'] == 'POST') { $uploader = new file_upload(".", 'files'); $whitelist = array('jpg' => 'image/jpeg', 'gif' => 'image/gif'); if ($uploader->upload($whitelist)) { $server = new ftp('domain.com', 'username', 'password'); if ($server->connect()) { $server->chdir('my_upload_folder'); if ($server->put('**file to upload**', '**upload location**')) { echo 'File uploaded'; } else { echo 'File could not be uploaded'; } } else { echo 'could not connect'; } } } ?> This would upload the file to your first server and send the file through ftp to the second server. Hope this helps!!! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.