2007年06月29日 星期五 17:42
运行之后目录创建出来了吗? 创建出来的目录是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
2007年06月29日 星期五 18:37
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
Zeuux © 2025
京ICP备05028076号