Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def save_file(file, path=''):
- filename = file._get_name()
- filename_wo_extension_index = filename.find(".")
- filename_wo_extension=filename[0:filename_wo_extension_index]
- #instance.icon = filename_wo_extension
- destination_new = os.path.join(ROOT_DIR, 'arches/Media/images/AssetIcons/')
- os.chdir(destination_new)
- if os.path.exists(destination_new) == "True":
- with open('%s' % filename, "wb+") as destination:
- for chunk in file.chunks():
- destination.write(chunk)
- else:
- with open('%s' % filename, "wb+") as destination :
- for chunk in file.chunks():
- destination.write(chunk)
- #add support for uploading icon file
- if 'file' in request.FILES:
- save_file(request.FILES['file'])
- else:
- #instance.icon = request.POST.get('icon')
- pass
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement