IsADirectoryError
IsADirectoryError: [Errno 21] Is a directory: '/home/abrarwali/PycharmProjects/xyz/EmailApp/attachments'
UPLOAD_FOLDER = os.path.join(os.getcwd() '/EmailApp', 'attachments')
app.config['UPLOAD_FOLDER'] = UPLOAD_FOLDER
files = request.files.getlist('attachment')
for file in files:
if file.filename == '':
flash('No selected file')
if file and allowed_file(file.filename):
file_name = secure_filename(file.filename)
file.save(os.path.join(app.config['UPLOAD_FOLDER']),file_name)
I don't follow because save
accepts a destination directory which I'm supplying and the filename to save. I have gone through StackOverflow solutions but I'm unable to fix this.
Any help is appreciated.
CodePudding user response:
it was typo, there is an extra and a missing )
in
file.save(os.path.join(app.config['UPLOAD_FOLDER']),file_name)
it should be
file.save(os.path.join(app.config['UPLOAD_FOLDER'],file_name))