这可能需要迁移到ServerFault,但我无法将文件上传到Django中的文件夹。
它在本地工作正常,但当我将文件上传到/opt/Webapp/userfiles
时,我得到以下内容:
[Thu Oct 23 13:21:32 2014] [error] [client 10.8.1.143] PHP Notice: Undefined property: a1234_Registrants::$name in /var/www/html/sugarcrm/include/SugarObjects/templates/basic/Basic.php on line 53
[Thu Oct 23 13:21:36 2014] [error] Internal Server Error: /upload/
[Thu Oct 23 13:21:36 2014] [error] Traceback (most recent call last):
[Thu Oct 23 13:21:36 2014] [error] File "/opt/.virtualenvs/smart/lib/python2.7/site-packages/django/core/handlers/base.py", line 111, in get_response
[Thu Oct 23 13:21:36 2014] [error] response = wrapped_callback(request, *callback_args, **callback_kwargs)
[Thu Oct 23 13:21:36 2014] [error] File "/opt/.virtualenvs/smart/lib/python2.7/site-packages/django/views/decorators/http.py", line 41, in inner
[Thu Oct 23 13:21:36 2014] [error] return func(request, *args, **kwargs)
[Thu Oct 23 13:21:36 2014] [error] File "/opt/Webapp/jobs/views.py", line 55, in upload
[Thu Oct 23 13:21:36 2014] [error] instance.save()
[Thu Oct 23 13:21:36 2014] [error] File "/opt/.virtualenvs/smart/lib/python2.7/site-packages/django/db/models/base.py", line 590, in save
[Thu Oct 23 13:21:36 2014] [error] force_update=force_update, update_fields=update_fields)
[Thu Oct 23 13:21:36 2014] [error] File "/opt/.virtualenvs/smart/lib/python2.7/site-packages/django/db/models/base.py", line 618, in save_base
[Thu Oct 23 13:21:36 2014] [error] updated = self._save_table(raw, cls, force_insert, force_update, using, update_fields)
[Thu Oct 23 13:21:36 2014] [error] File "/opt/.virtualenvs/smart/lib/python2.7/site-packages/django/db/models/base.py", line 699, in _save_table
[Thu Oct 23 13:21:36 2014] [error] result = self._do_insert(cls._base_manager, using, fields, update_pk, raw)
[Thu Oct 23 13:21:36 2014] [error] File "/opt/.virtualenvs/smart/lib/python2.7/site-packages/django/db/models/base.py", line 732, in _do_insert
[Thu Oct 23 13:21:36 2014] [error] using=using, raw=raw)
[Thu Oct 23 13:21:36 2014] [error] File "/opt/.virtualenvs/smart/lib/python2.7/site-packages/django/db/models/manager.py", line 92, in manager_method
[Thu Oct 23 13:21:36 2014] [error] return getattr(self.get_queryset(), name)(*args, **kwargs)
[Thu Oct 23 13:21:36 2014] [error] File "/opt/.virtualenvs/smart/lib/python2.7/site-packages/django/db/models/query.py", line 921, in _insert
[Thu Oct 23 13:21:36 2014] [error] return query.get_compiler(using=using).execute_sql(return_id)
[Thu Oct 23 13:21:36 2014] [error] File "/opt/.virtualenvs/smart/lib/python2.7/site-packages/django/db/models/sql/compiler.py", line 919, in execute_sql
[Thu Oct 23 13:21:36 2014] [error] for sql, params in self.as_sql():
[Thu Oct 23 13:21:36 2014] [error] File "/opt/.virtualenvs/smart/lib/python2.7/site-packages/django/db/models/sql/compiler.py", line 877, in as_sql
[Thu Oct 23 13:21:36 2014] [error] for obj in self.query.objs
[Thu Oct 23 13:21:36 2014] [error] File "/opt/.virtualenvs/smart/lib/python2.7/site-packages/django/db/models/fields/files.py", line 301, in pre_save
[Thu Oct 23 13:21:36 2014] [error] file.save(file.name, file, save=False)
[Thu Oct 23 13:21:36 2014] [error] File "/opt/.virtualenvs/smart/lib/python2.7/site-packages/django/db/models/fields/files.py", line 89, in save
[Thu Oct 23 13:21:36 2014] [error] self.name = self.storage.save(name, content)
[Thu Oct 23 13:21:36 2014] [error] File "/opt/.virtualenvs/smart/lib/python2.7/site-packages/django/core/files/storage.py", line 51, in save
[Thu Oct 23 13:21:36 2014] [error] name = self._save(name, content)
[Thu Oct 23 13:21:36 2014] [error] File "/opt/.virtualenvs/smart/lib/python2.7/site-packages/django/core/files/storage.py", line 219, in _save
[Thu Oct 23 13:21:36 2014] [error] fd = os.open(full_path, flags, 0o666)
[Thu Oct 23 13:21:36 2014] [error] OSError: [Errno 13] Permission denied: '/opt/Webapp/userfiles/Chrysanthemum.jpg'
文件夹的权限如下所示:
drwxrwxrwx. 2 apache root 4096 Oct 20 14:22 userfiles
我想知道源文件的权限是否需要更改为?或者可能是群组权限?
请为您认为合适的问题添加任何额外标签,因为我不确定是否已将其全部覆盖。
答案 0 :(得分:0)
在被拒绝之前,我尽可能地写/opt/
。 /opt/
内的任何文件夹都有权限。
我使用/var/www/
保存我的文件似乎更合适。