Python论坛  - 讨论区

标题:[python-chinese] Django 本地好好的,部属到lighttpd 上就上传不了文件:(

2007年06月29日 星期五 17:42

马踏飞燕 honeyday.mj在gmail.com
星期五 六月 29 17:42:43 HKT 2007

运行之后目录创建出来了吗?
创建出来的目录是755或777吗?
看看那个目录的用户是谁?不会是nobody之类的吧?

剩下的就想不出什么原因了。。。

在 07-6-29,Neo Chen<openunix在163.com> 写道:
> automkdir() 这个就是用来创建子目录的..
>
>
>
> def upload(request,id):
>    info['folder'] = id
>    if request.method == 'POST':
>        file_obj = request.FILES.get('photo', None)
>        if file_obj:
>            basename, ext = os.path.splitext(file_obj['filename'])
>            filename = file_obj['filename']
>            error_msg = ""
>            if ext.lower() not in [".jpg", ".jpeg", ".bmp", ".png", ".gif", ".txt"]:
>                error_msg = _("The image file must have one of the following extensions: %(exts)s") % {"exts": ".jpg, .jpeg, .bmp, .png, .gif"}
>            else:
>                # 保存文件内容
>
>                path = automkdir()
>                fname = path + '/' + str(uuid.uuid5(uuid.NAMESPACE_URL,basename))+ext
>                f = open(fname,'wb')
>                f.write(file_obj['content'])
>                f.close()
>                hexdigest = md5.new(file_obj['content']).hexdigest()
>                request.session['upload_file'] = fname
>                try:
>                    if Library.objects.get(hexdigest=hexdigest):
>                        print '-----------------------------'
>                        info['folder'] = id
>                        info['message'] = '你需要上传一个文件,已经存在!'
>                        return render_to_response('error/error.html', info)
>                except:
>                    pass
>                lib = Library(folder=Folder(id), name=filename,path=fname,hexdigest=hexdigest, content='add by neo')
>                lib.save()
>                return HttpResponseRedirect('/album/'+id+'/photo/')
>    else:
>        return render_to_response('upload/index.html', info)
> -----------------------------------------------
> def mkdir(path):
>    os.makedirs(path,0755)
> def automkdir():
>    now = photo_home+'/'+ datetime.now().strftime("%Y/%m/%d")
>    logs(now)
>    # "%Y/%m/%d/%H/%M/%S"
>    if not os.path.isdir(now):
>        mkdir(now)
>    return now
>
> ----- Original Message -----
> From: "马踏飞燕" <honeyday.mj在gmail.com>
> To: <python-chinese在lists.python.cn>
> Sent: Friday, June 29, 2007 9:40 AM
> Subject: Re: [python-chinese]Django 本地好好的,部属到lighttpd 上就上传不了文件:(
>
>
> > 2007/6/28, Neo Chen <openunix在163.com>:
> >>
> >> 大家给看看..
> >> http://album.bg7nyt.cn/album/
> >
> > 大哥,这个错误咋看啊?!
> > 连个错误信息都没有。
> >
> > 不过你是不是对每个分类建立了子目录啊?
> > 并且在上传文件的时候,子目录还没有创建出来,就会报错了。
> >
> > python直接open文件的话,如果目录不存在就报错,但是文件不存在的话他会自动创建一个。
> >
> > 至于别的原因,最好是把traceback信息打印出来吧。
> > _______________________________________________
> > python-chinese
> > Post: send python-chinese在lists.python.cn
> > Subscribe: send subscribe to python-chinese-request在lists.python.cn
> > Unsubscribe: send unsubscribe to  python-chinese-request在lists.python.cn
> > Detail Info: http://python.cn/mailman/listinfo/python-chinese
> _______________________________________________
> python-chinese
> Post: send python-chinese在lists.python.cn
> Subscribe: send subscribe to python-chinese-request在lists.python.cn
> Unsubscribe: send unsubscribe to  python-chinese-request在lists.python.cn
> Detail Info: http://python.cn/mailman/listinfo/python-chinese

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2007年06月29日 星期五 18:37

cun heise cunheise在hotmail.com
星期五 六月 29 18:37:35 HKT 2007

lighttpd default ʹÓÃlighttpd:lighttpdÄãÒª¿´¿´Õâ¸öaccountʱºòÓÐpermission 
to write


>From: "Âí̤·ÉÑà" <honeyday.mj在gmail.com>
>Reply-To: python-chinese在lists.python.cn
>To: python-chinese在lists.python.cn
>Subject: Re: [python-chinese]Django ±¾µØºÃºÃµÄ,²¿Êôµ½lighttpd ÉϾÍÉÏ´«²»ÁË
Îļþ:(
>Date: Fri, 29 Jun 2007 17:42:43 +0800
>
>运行之后目录创建出来了吗ï¼?>创建出来的目录是755æˆ?77å
—?
>看看那个目录的用户是谁?不会是nobody之类的吧ï¼?>
>剩下的就想不出什么原因了。。ã€?>
>åœ?07-6-29,Neo Chen<openunix在163.com> 写道ï¼?> > automkdir() 这个就æ
˜¯ç”¨æ¥åˆ›å»ºå­ç›®å½•çš„..
> >
> >
> >
> > def upload(request,id):
> >    info['folder'] = id
> >    if request.method == 'POST':
> >        file_obj = request.FILES.get('photo', None)
> >        if file_obj:
> >            basename, ext = os.path.splitext(file_obj['filename'])
> >            filename = file_obj['filename']
> >            error_msg = ""
> >            if ext.lower() not in [".jpg", ".jpeg", ".bmp", ".png", 
".gif", ".txt"]:
> >                error_msg = _("The image file must have one of the 
following extensions: %(exts)s") % {"exts": ".jpg, .jpeg, .bmp, .png, 
..gif"}
> >            else:
> >                # 保存文件内容
> >
> >                path = automkdir()
> >                fname = path + '/' + 
str(uuid.uuid5(uuid.NAMESPACE_URL,basename))+ext
> >                f = open(fname,'wb')
> >                f.write(file_obj['content'])
> >                f.close()
> >                hexdigest = md5.new(file_obj['content']).hexdigest()
> >                request.session['upload_file'] = fname
> >                try:
> >                    if Library.objects.get(hexdigest=hexdigest):
> >                        print '-----------------------------'
> >                        info['folder'] = id
> >                        info['message'] = '你需要上传一个文ä»?å·
²ç»å­˜åœ¨ï¼?
> >                        return render_to_response('error/error.html', 
info)
> >                except:
> >                    pass
> >                lib = Library(folder=Folder(id), 
name=filename,path=fname,hexdigest=hexdigest, content='add by neo')
> >                lib.save()
> >                return HttpResponseRedirect('/album/'+id+'/photo/')
> >    else:
> >        return render_to_response('upload/index.html', info)
> > -----------------------------------------------
> > def mkdir(path):
> >    os.makedirs(path,0755)
> > def automkdir():
> >    now = photo_home+'/'+ datetime.now().strftime("%Y/%m/%d")
> >    logs(now)
> >    # "%Y/%m/%d/%H/%M/%S"
> >    if not os.path.isdir(now):
> >        mkdir(now)
> >    return now
> >
> > ----- Original Message -----
> > From: "马踏飞燕" <honeyday.mj在gmail.com>
> > To: <python-chinese在lists.python.cn>
> > Sent: Friday, June 29, 2007 9:40 AM
> > Subject: Re: [python-chinese]Django 本地好好çš?部属到lighttpd ä¸
Šå°±ä¸Šä¼ ä¸äº†æ–‡ä»¶:(
> >
> >
> > > 2007/6/28, Neo Chen <openunix在163.com>:
> > >>
> > >> 大家给看çœ?.
> > >> http://album.bg7nyt.cn/album/
> > >
> > > 大哥,这个错误咋看啊?!
> > > 连个错误信息都没有ã€?> > >
> > > 不过你是不是对每个分类建立了子目录啊ï¼?> > > 并且
在上传文件的时候,子目录还没有创建出来,就会报错了
�> > >
> > > python直接open文件的话,如果目录不存在就报错,但是
文件不存在的话他会自动创建一个ã€?> > >
> > > 至于别的原因,最好是把traceback信息打印出来吧ã€?> > 
> _______________________________________________
> > > python-chinese
> > > Post: send python-chinese在lists.python.cn
> > > Subscribe: send subscribe to python-chinese-request在lists.python.cn
> > > Unsubscribe: send unsubscribe to  
python-chinese-request在lists.python.cn
> > > Detail Info: http://python.cn/mailman/listinfo/python-chinese
> > _______________________________________________
> > python-chinese
> > Post: send python-chinese在lists.python.cn
> > Subscribe: send subscribe to python-chinese-request在lists.python.cn
> > Unsubscribe: send unsubscribe to  
python-chinese-request在lists.python.cn
> > Detail Info: http://python.cn/mailman/listinfo/python-chinese
>_______________________________________________
>python-chinese
>Post: send python-chinese在lists.python.cn
>Subscribe: send subscribe to python-chinese-request在lists.python.cn
>Unsubscribe: send unsubscribe to  python-chinese-request在lists.python.cn
>Detail Info: http://python.cn/mailman/listinfo/python-chinese

_________________________________________________________________
ÏíÓÃÊÀ½çÉÏ×î´óµÄµç×ÓÓʼþϵͳ¡ª MSN Hotmail¡£ http://www.hotmail.com 


[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

如下红色区域有误,请重新填写。

    你的回复:

    请 登录 后回复。还没有在Zeuux哲思注册吗?现在 注册 !

    Zeuux © 2025

    京ICP备05028076号