Hi everybody. I have never built a website that needed a remote image server but I want this current project to scale if necessary. My hosting company is much more affordable than any cloud hosting offering so I simply want to set up my own image server(s). My question is what is the best way to save the images to a remote image server (linux) using PHP? CURL, FTP, POST, file_put_contents, sockets? I'm pretty sure I could use one or several of these methods. I'm just not sure which way is recommended. Grant
Hi, I suggest you to use SSH2, for me that was the best way to communicate with remote linux servers.
Question: if these servers are cohost on same location, why not just use Linux built in functions to create a fail over backup of the image hosting? No need to create any kind of php potentially creating security issues, just set up a cron job to copy across internal network and delete the files uploaded to the production server.
I would use SSHFS or SFTP to mount the hard drive on your server. So to your server, you will be writing the data to /locationx.
thanks everybody for the input. i like these ideas. if anyone has an opinion on it feel free to comment.
I would use Curl. $ch = curl_init("http://www.remotepage.com/upload.php"); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CUROPT_POSTFIELDS, array('fileupload' => '@'.$_FILES['theFile']['tmp_name'])); echo curl_exec($ch); Code (markup): At the remote server php should write the file out and respond with full url of the location. Then at local server I would write the url to sql.
Why would you use external bandwidth when the servers seemingly are on the same network, or at least the same location, and should be able to communicate via way faster LAN?
Fair point PoPSiCLe. I'm sure there are people wondering how to do this with servers that are off of the local network as well. Those people will appreciate Meglepett's comment.