我试图上传相同的图像在同一个迭代两次。不知道为什么,但是下面的代码只上传了第一次save()
。第二,我仍然在目录中的文件,但图像有0字节
path_for_images_large = os.path.join(current_app.static_folder, "uploads/gallery/"+str(company.id)+"/large/")
path_for_images_small = os.path.join(current_app.static_folder, "uploads/gallery/"+str(company.id)+"/small/")
if request.method == 'POST':
for key, f in request.files.items():
if key.startswith('file'):
f.save(os.path.join(path_for_images_small, f.filename))
f.save(os.path.join(path_for_images_large, f.filename))
在第一次保存之后,您就到了文件的末尾,没有什么要写的了,请键入
f.seek(0)
移到开头相关问题 更多 >
编程相关推荐