0

I have a python script I am running with a post request. The script is located in my cgi-bin and at the end of the script I am trying to upload a file to the /var/www/html/ folder and I am doing it like this

myFile= open("/var/www/html/file.html","w")
myFile.write("<html><body><p>test</p></body></html>")
myFile.close()

But I keep getting

<type 'exceptions.IOError'>: [Errno 13] Permission denied: '/var/www/html/file.html' 

What is going wrong?

spen123
  • 3,464
  • 11
  • 39
  • 52

1 Answers1

1

The error itself is already clear, your don't have enough permission to write to /var/www/html. It might be related the owner of the directory. If the owner is another user, then your current user don't have the write permission to the directory, the error would occur.

Shang Wang
  • 24,909
  • 20
  • 73
  • 94
  • the cgi-bin is 755 so is my python script? – spen123 Aug 11 '15 at 19:35
  • Updated the answer. Does `var/www/html` owned by a different user, like `apache` or something? – Shang Wang Aug 11 '15 at 19:37
  • Right so I think it might be owned by apache, but I know its bad but just to try I changed var, www, cgi-bin to 777 and it still didn't work do it matter the permission of the cgi-bin or of the html folder – spen123 Aug 11 '15 at 19:40