Image transfer

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
vivekjain
Forum Commoner
Posts: 76
Joined: Thu Jan 08, 2004 12:38 am

Image transfer

Post 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
bubblenut
Forum Newbie
Posts: 20
Joined: Sat Feb 03, 2007 4:16 am
Location: London

Post 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.
Post Reply