我有一个问题,本地版本的django正在按预期处理图像上传,但我的服务器不是。注意:我在MediaTemple.net(网格服务器)上使用Django容器
这是我的代码。
def view_settings(request):
<snip>
if request.POST:
success_msgs = ()
mForm = MainProfileForm(request.POST, request.FILES, instance = mProfile)
pForm = ChangePasswordForm(request.POST)
eForm = ChangeEmailForm(request.POST)
if mForm.is_valid():
m = mForm.save(commit = False)
if mForm.cleaned_data['avatar']:
m.avatar = upload_photo(request.FILES['avatar'], settings.AVATAR_SAVE_LOCATION)
m.save()
success_msgs += ('profile pictured updated',)
<snip>
def upload_photo(data,saveLocation):
savePath = os.path.join(settings.MEDIA_ROOT, saveLocation, data.name)
destination = open(savePath, 'wb+')
for chunk in data.chunks():
destination.write(chunk)
destination.close()
return os.path.join(saveLocation, data.name)
这就是它变得笨拙的地方,我希望有人可以解释这个错误,因为a)它是错误的错误代码,或者b)文件在完全处理之前发生了什么。回顾一下,该文件实际上已上传到目标目录中的服务器 - 然而这个错误信息仍然存在。
/ user / settings
中的IOError[Errno 2]没有这样的文件或目录: 的u '/家/ user66666 /域/ example.com / HTML /媒体/图像/化身/ DSC03852.JPG'
环境:
请求方法:POST请求URL:
http://111.111.111.111:2011/user/settings
Django版本:1.0.2最终Python
版本:2.4.4已安装的应用程序:
['django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites','ctrlme',
'usertools','easy_thumbnails']
已安装的中间件:
( 'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware')
回溯:文件 “/home/user6666/containers/django/leonidas/usertools/views.py” 在view_settings
m.avatar = upload_photo(request.FILES ['avatar'], settings.AVATAR_SAVE_LOCATION)文件 “/home/user666666/containers/django/leonidas/usertools/functions.py” 在upload_photo
- 醇>
destination = open(savePath,'wb +')