Send file to remote server with PHP

3

I have a PHP system that I have developed and put online on my server at DigitalOcean, the site has two parts, which visitors will access and the administration area where I manage this site and put the content users will have access.

I left the administration area on my local machine for security reasons since I only had access and had no reason to put it online, I made the connection to the database that is in DigitalOcean with the admin area that is in my local machine and everything works perfectly, but it has a problem that I do not know how to solve.

I need when registering information to send images of the items that I registered in the system, that's the problem, I do not know how to do it, and to make sure to post those images from my local machine to my Linux server on DigitalOcean, I currently send these images commits in my local Git repository to my remote git server, which is extremely wrong and causes me to commit at all times when registering new items simply for the images to be sent.

How can I upload these images using the PHP language securely to my remote server?

OBS: My server in DigitalOcean I only access it via SSH from my linux terminal on the local machine, it would have to be a way to allow this upload with an active SSH server on the remote server

>     
asked by anonymous 02.12.2016 / 20:22

2 answers

5

The rsync , for Gnu / Linux, synchronizes folders, so whenever you add images to your local folder they will be sent to the remote directory. You can also configure it to avoid duplication and backup.

If you are a Windows user, you can count on WinSCP that enables the same functionality.

    
02.12.2016 / 23:29
2

On the outside of the application, as you have done, the ideal would be to use SFTP. I do not particularly use Digital Ocean, but everywhere I use FTP and SFTP I prefer Filezilla.

These articles will be useful:

Now inside the application, you can also make it SFTP and upload, obviously a little work but it will be cool, certainly.

Here you can use the PHP extension SSH2, but it is not installed by default, or use an external library like phpseclib.

There is a question in Stackoverflow in English with two good examples using both solutions, and I use and link to a comment that shows accessing the server accessing the keys, without password.

02.12.2016 / 21:50