Commit ed268c24 by aagusti

perbaikan upload

1 parent f4684762
...@@ -399,7 +399,7 @@ class SaveFile(object): ...@@ -399,7 +399,7 @@ class SaveFile(object):
# number. # number.
def create_fullpath(self, ext=''): def create_fullpath(self, ext=''):
while True: while True:
filename = get_random_string() + ext filename = get_random_string(32) + ext
full_path = os.path.join(self.dir_path, filename) full_path = os.path.join(self.dir_path, filename)
if not os.path.exists(full_path): if not os.path.exists(full_path):
return full_path return full_path
...@@ -478,14 +478,15 @@ class Upload(SaveFile): ...@@ -478,14 +478,15 @@ class Upload(SaveFile):
return filename return filename
def save_fp(self, upload): def save_fp(self, upload):
if 'fp' not in upload or upload['fp'] == b'': if 'fp' not in upload or upload['fp'] == b'' or not upload['fp'] or not upload['size']:
if "filename" in upload: if "filename" in upload:
return upload['filename'] return upload['filename']
return return
filename = upload['filename'] filename = upload['filename']
input_file = upload['fp'] input_file = upload['fp']
ext = get_ext(filename) ext = get_ext(filename)
return self.save_to_file(input_file, ext) filename = self.save_to_file(input_file, ext)
return os.path.split(filename)[1]
def saves(self, uploads): def saves(self, uploads):
d = {} d = {}
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!