phyloforfun commited on
Commit
cc7c4ef
1 Parent(s): 32e89be

file upload gallery

Browse files
Files changed (1) hide show
  1. app.py +2 -2
app.py CHANGED
@@ -283,13 +283,13 @@ def save_uploaded_file(directory, img_file, image=None):
283
  if not os.path.exists(directory):
284
  os.makedirs(directory)
285
  # Assuming the uploaded file is an image
286
- try:
287
  with Image.open(img_file) as image:
288
  full_path = os.path.join(directory, img_file.name)
289
  image.save(full_path, "JPEG")
290
  # Return the full path of the saved image
291
  return full_path
292
- except:
293
  full_path = os.path.join(directory, img_file.name)
294
  image.save(img_file, "JPEG")
295
  return directory
 
283
  if not os.path.exists(directory):
284
  os.makedirs(directory)
285
  # Assuming the uploaded file is an image
286
+ if image is None:
287
  with Image.open(img_file) as image:
288
  full_path = os.path.join(directory, img_file.name)
289
  image.save(full_path, "JPEG")
290
  # Return the full path of the saved image
291
  return full_path
292
+ else:
293
  full_path = os.path.join(directory, img_file.name)
294
  image.save(img_file, "JPEG")
295
  return directory