PHP Writing to a file on another server

I need to write a file that is on another server using php.

So, I get user data from a form on one server, and then I need to write to a text file located on another server. Do I need to authenticate or something like that?

The second server I need to write is a Windows server. This is problem?

Thank!

+3
source share
5 answers

No problem if you write on both servers, you can accomplish this using PHP FTP .

Make sure that you have the correct permissions to write files to the servers, or your code will not work and be denied access.

+1
source

(Windows) , . :

  • Windows ( - Linux, Samba smbclient, . Windows, , ​​ Z: )
  • FTP ( FTP-, FileZilla, cURL - PHP )
  • HTTP ( Apache + PHP IIS/.Net - Windows , POST . cURL HTTP POST PHP)
  • SSH ( OpenSSH scp)

HTTP-, ( Apache ), .

+3

, , ...

, , - , txt, , cURL, cron, x .

    $ch = curl_init(); 

    // set URL and other appropriate options 
    curl_setopt($ch, CURLOPT_URL, $url); 
    curl_setopt($ch, CURLOPT_HEADER, false); 
    curl_setopt($ch, CURLOPT_BINARYTRANSFER, true); 
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); 

    set_time_limit(3600); # 5 minutes for PHP 
    curl_setopt($ch, CURLOPT_TIMEOUT, 3600); # and also for CURL 

    $outfile = fopen( $dirname, 'wb'); 
    curl_setopt($ch, CURLOPT_FILE, $outfile); 

    // grab file from URL 
    $response = curl_exec($ch); 
    fclose($outfile); 

    // close CURL resource, and free up system resources 
    curl_close($ch); 

`

, FTP - . , , .

script mp3 . - 100-200 , .

+2

php ftp- .net ftp

ftp

, http://nl.php.net/ftp

ftp ?

ajax

script, , http script, php/asp

0

SFTP, , cURL.

0

Source: https://habr.com/ru/post/1730061/


All Articles