我有一个代码,它可以工作,但它不返回文件的实际名称
视图.py:
def upload_file(request):
getusername = ''
getfirstname = ''
getemail = ''
getpassword = ''
if request.method == 'POST':
getusername = request.POST['username']
getfirstname = request.POST['first_name']
def handle_uploaded_file(f):
destination = open('media/filename', 'wb+')
for chunk in f.chunks(): filename = form.clean_data['file'].name
destination.write(chunk)
destination.close()
getemail = request.POST['email']
form = UploadFileForm(request.POST, request.FILES)
filename = request.FILES['file']
def handle_uploaded_file(f):
destination = open('media/filename', 'wb+')
for chunk in f.chunks():
destination.write(chunk)
destination.close()
在forms.py
filename = form.clean_data['file'].name