Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Creating a file on another server using PHP file functionality

Tags:

php

I have a script on my one server and I want that script to create a file on another server of mine using PHP, NOT VIA FTP?

like image 983
Elitmiar Avatar asked Oct 26 '22 20:10

Elitmiar


1 Answers

There are many ways to do this. I'd pick the first one myself because it's easiest to set up:

  • If you have PHP+Apache on another server, just call some script on the other server using file_get_contents with http URL as filename or use cURL if you need to POST file contents as well.
  • If the servers are in same network (LAN, VPN) you can use Windows shares/Samba or NFS to mount a remote directory to you local filesystem and simply write to file directly using fopen/fwrite functions
  • Use SSH via SCP or SFTP
like image 174
Milan Babuškov Avatar answered Nov 13 '22 15:11

Milan Babuškov