0

I'm trying to write a file text from PHP file and save it in another PC in the same network, so that is what I write :

$myfile = fopen("192.168.100.18/file.txt", "w") or die("Error!");

so I got an error message, what should I do ?

** note: I'm using Linux for both PCs

Miss Pixel
  • 13
  • 3

1 Answers1

0

To achieve this you need to call a script on the other pc, so the URL would be like this:

PHP on the request side:

<?php

file_get_contents("192.168.100.18/save-file.php");

?>

PHP on the recipient side:

Create a file at the root called save-file.php and set the contents of the file to the following script:

<?php

file_put_contents("file.txt", "some string");

?>

This way, every time you will load the script on the first pc it will request the save-file.php script on the other pc which in turn will save the file.

jacobdo
  • 1,605
  • 3
  • 15
  • 34
  • Thank you, I did that but unfortunately it didn't work, writing the path in this way `ip/filename` doesn't work – Miss Pixel Mar 01 '17 at 08:10