After downloading the file from the user interface, how to create a new directory with the current time stamp in / opt / files / and copy the downloaded zip file to this directory and unzip the zip file to a new directory and save the new directory name in a variable
def upload_info(request):
if request.method == 'POST':
file=request.FILES['file']
dir = "/opt/files"
file_name = "%s/%s" % (dir, file.name)
form = UploadFileForm(request.POST, request.FILES)
try:
handle_uploaded_file( file_name , file )
def handle_uploaded_file(file_name,f):
destination = open(file_name, 'wb+')
for chunk in f.chunks():
destination.write(chunk)
destination.close()
return
source
share