From 2cc260d098c3a875194c54b1b55fac8d94be295f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=BD=A6=E4=BA=AE=E4=BA=AE?= Date: Thu, 12 Jan 2017 23:57:38 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E4=B8=8A=E4=BC=A0=E5=8A=9F?= =?UTF-8?q?=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- blog/views.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/blog/views.py b/blog/views.py index 66827f9..555a07d 100644 --- a/blog/views.py +++ b/blog/views.py @@ -208,14 +208,15 @@ def fileupload(request): if request.method == 'POST': fname = '' timestr = datetime.datetime.now().strftime('%Y/%m/%d') - basepath = os.path.join(r'/var/www/resource/image/', timestr) + basepath = os.path.join(r'image/', timestr) if not os.path.exists(basepath): os.makedirs(basepath) - for filename, file in request.FILES.iteritems(): + fname = '' + for filename in request.FILES: fname = filename savepath = os.path.join(basepath, filename) with open(savepath, 'wb+') as wfile: - for chunk in file.chunks(): + for chunk in request.FILES[filename].chunks(): wfile.write(chunk) return HttpResponse('https://resource.lylinux.net/' + 'image/' + timestr + '/' + fname)