I am running Ubuntu with an Apache webserver with Mod_python. The root directory of the web server is /var/www
I have a form for uploading files. The uploaded files should be stored in folder /var/www/xy/uploads
by a python script.
But when I use this script, I receive an error:
Permission denied: '/var/www/xy/uploads/316.jpg'
Here the relevant parts of the code, that should handle the received files:
targetdir_path = "/var/www/xy/uploads"
newid = 316
f = open(os.path.join(targetdir_path,str(newid)+'.jpg'),"w")
I assume, there is a problem with the access rights of the uploads directory. They are set to: drwxr-xr-x
Can anyone explain me, what I need to change? Thanks for the help!
Your directory permissions are set for only allowing writing for the owner of the directory. try this:
Also, I'd advise against using
mod_python
as it is deprecated, look intomod_wsgi
instead.