0

I am using file_put_contents and the path is C:\foldername its working fine in my local. When I tried it on my dev ennvironment I thought its not working because its not saving in my computer. It is saving in my dev environment.

file_put_contents("C:\foldername", $data);

  1. How to use this and have the path to point to client computer?
  2. What should i put in the path so that it will be stored in the client of users not on dev environment?
guradio
  • 15,524
  • 4
  • 36
  • 57
  • 2
    PHP runs on the server, not the client. It can't put to a file on the client, you need to download the file for that. – Barmar Sep 17 '19 at 01:34
  • @Barmar is there a way I can save a file to client's computer? other than the `file_put_content` if its not possible for `file_put_content` to do what i need? – guradio Sep 17 '19 at 01:39
  • 1
    You need to use to headers. Take a read here: https://stackoverflow.com/questions/8485886/force-file-download-with-php-using-header – gustavo.lei Sep 17 '19 at 02:25

0 Answers0