phyloforfun commited on
Commit
49fb854
1 Parent(s): cb013ae

file upload gallery

Browse files
Files changed (1) hide show
  1. app.py +7 -5
app.py CHANGED
@@ -282,8 +282,10 @@ def save_uploaded_file(directory, img_file):
282
  os.makedirs(directory)
283
  # Assuming the uploaded file is an image
284
  with Image.open(img_file) as image:
285
- # Save the image with a jpg extension
286
- image.save(os.path.join(directory, img_file.name), "JPEG")
 
 
287
 
288
  def delete_directory(dir_path):
289
  try:
@@ -1096,9 +1098,9 @@ def content_tab_settings():
1096
  validate_dir(st.session_state['dir_uploaded_images'])
1097
  # Process the new iamges
1098
  for uploaded_file in uploaded_files:
1099
- print(uploaded_file)
1100
- st.session_state['input_list'].append(os.path.join(st.session_state.dir_home,'uploads',uploaded_file))
1101
- save_uploaded_file(st.session_state['dir_uploaded_images'], uploaded_file)
1102
 
1103
  with col_local_2:
1104
  if st.session_state['input_list']:
 
282
  os.makedirs(directory)
283
  # Assuming the uploaded file is an image
284
  with Image.open(img_file) as image:
285
+ full_path = os.path.join(directory, img_file.name)
286
+ image.save(full_path, "JPEG")
287
+ # Return the full path of the saved image
288
+ return full_path
289
 
290
  def delete_directory(dir_path):
291
  try:
 
1098
  validate_dir(st.session_state['dir_uploaded_images'])
1099
  # Process the new iamges
1100
  for uploaded_file in uploaded_files:
1101
+ file_path = save_uploaded_file(st.session_state['dir_uploaded_images'], uploaded_file)
1102
+ st.session_state['input_list'].append(file_path)
1103
+ print(uploaded_file.name)
1104
 
1105
  with col_local_2:
1106
  if st.session_state['input_list']: