python - Flask WTForms cannot save file to different directory -
I am learning the flask with WTForms and I am trying to upload the file to the server. The structure of my app is like:
| App | - mod_users | - models.py | - forms.py | Views.py | - Template | - Stable | Run.py | Config.py
In my thoughts I have:
@ mod.route ('/ post /', methods = ['GET'] 'POST ']) DEF post (): form = postform () if form.validate_on_submit (): filename = secure_filename (form.imageFile.data.filename) form.imageFile.data.save (' / app / static / images / books / '+ File name)
If I have form.imageFle.data.save (filename) then the app works and saves The image in the same folder where the "app" is located but when I change it above, I have an error:
IOError: [Aron 2] Such a file or instruction Not enough: '/app/static/images/testupload/test.png' to upload / app / stat / images / testupload /
P> How do I fix this problem? Thank you.
Understand this investigation that the directory "app / static / image / test upload /" leading / unopened .
Comments
Post a Comment