0

It is possible to open a txt file from desktop to my webserver?
I have tried fopen but It cant open the stream.

Code:

$txtfile = fopen("C:\Users\steve\Desktop\AntiCheat.txt","r");
echo $txtfile;

The Error message:

Warning: fopen(C:\Users\steve\Desktop\AntiCheat.txt): failed to open stream: No such file or directory   

This works fine If I using XAMPP but on my webserver it does not works

  • Does your web server reside on the same Windows computer as the file? – S. Dev May 28 '18 at 17:46
  • No, but If I'm using `` the file can be uploaded by clicking the button but I dont want it so – Freddy Gerogin May 28 '18 at 17:48
  • Possible duplicate of [PHP - Failed to open stream : No such file or directory](https://stackoverflow.com/questions/36577020/php-failed-to-open-stream-no-such-file-or-directory) – Sheikh Hasib May 28 '18 at 17:51

1 Answers1

0

This works fine If I using XAMPP but on my webserver it does not works

XAMPP is a package that includes a web server, so presumably, you mean that it doesn't work if you use a web server that is running on a different computer.

This shouldn't be a surprise as the other computer won't have your hard disk in it, so it won't have your C drive or your files.

You need to either:

  • Share your file over the network to the computer running the web server (since the web server probably doesn't run on your LAN, this is likely to be logistically challenging).
  • Copy the file to the computer running the web server.
Quentin
  • 914,110
  • 126
  • 1,211
  • 1,335