Page 1 of 1

Image transfer

Posted: Thu Apr 05, 2007 2:49 am
by vivekjain
Hi,
We are working on an application using PHP, MySQL. One of the features is to upload an image, and the same image needs to be copied on different servers as well. We did use the FTP functions, but we just realized that the FTP function dosent seem to be working on the other servers. Is there anothey way to do this? The server is Linux. Have heard that using Shell its possible, but not sure how to do this. Any ideas??

Thanks

Regards,
Vivek

Posted: Thu Apr 05, 2007 7:04 am
by bubblenut
We do the same kind of thing with uploading images across our image servers. We use scp via the exec php function. To make the process easier make sure you have your DSA keys set up correctly between the two machines. This is more linux admin than PHP really.

Check out the home directory of the process which your webserver runs under on the machine you're copying the images from. There should be a hidden directory called '.ssh' (you can list it by typing ls -a). Change to this directory and you should find a number of files among which will be authorized_keys2. You need to copy the first line of this file to the same file (in the home directory of the user you're going to be using) on the destination machine. You should now be able to ssh from the source machine as the webserver user to the destination machine as the user you've decided to use. From here on in using the scp command should be pretty straightforward.