fopen - failed to open stream: Permission denied

Leon picture Leon · Aug 23, 2017 · Viewed 7.6k times · Source

Is it possible to write data to CSV while the file is opened from desktop? Because I am trying to write some input data to CSV when user submit the form, but I am getting above error when the file is opened from my desktop. My system will only write to csv when I close the file.

Error when meeting the line $fp = fopen("C:\Users\lenovo\Desktop\sample.csv", "w");

Answer

Abhishek Kumar picture Abhishek Kumar · Jul 2, 2018

Change the permission of the file sample.csv by using the following command on the terminal in the folder where the file is-

chmod 777 sample.csv