【发布时间】:2014-10-23 12:30:50
【问题描述】:
这可能需要迁移到 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
我想知道是否需要将源文件的权限更改为?或者可能是组权限?
请在您认为合适的问题中添加任何额外的标签,因为我不确定我是否涵盖了所有标签。
【问题讨论】:
-
我认为这个位置有一些限制。上传到 /var/www 似乎可行。