I have 2 tuples.
1th tuple - files to remove (got with SQL request from DB).
2th tuple - files to save (got from html form).
Both tuples returns str file names.
I try to remove old and save new files at same time like that:
old_name = (get_image_name.img_1, get_image_name.img_2, get_image_name.img_3)
new_name = (request.files['img_1'], request.files['img_2'], request.files['img_3'])
for i in range(3):
new_name[i].save(os.path.join(app.config['UPLOAD_FOLDER'] + 'test_folder/', new_name[i].filename))
os.remove(os.path.join(app.config['UPLOAD_FOLDER'] + 'test_folder/', old_name[i]))
If i try to save new 2 files and remove old 2 files, code works good.
And if i try to save new 3 files and remove old 2 files, code works good.
But if i will try to save new 2 files and remove 3 old files, then 3th old file will be not remove.
How to save and remove any count of files at same time?