Jump to content

upload the files across the server


phani_kosaraju

Recommended Posts

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.

 

 

Link to comment
Share on other sites

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!!!

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.