I am developing a project on Ionic I have a server mounted on Flask and I would like to be able to send images and treat them with this one.
I am currently doing the following:
uploadFile(img) {
let postParams = { file: img };
this.http.setDataSerializer("json");
this.http.post('http://46.101.150.118:5000/upload', postParams,
{
"Accept": "application/json",
"Content-Type": "application/json"
}
).then(data => {
this.drawCanvas(data);
}).catch(error => {
console.log(error);
});}
Flask Code:
@app.route('/upload', methods=['POST']) def upload():
file = request.files['file']
if file and allowed_file(file.filename):
filename = secure_filename(file.filename)
file.save(os.path.join(app.config['UPLOAD_FOLDER'], filename))
and in flask I receive it as "data" and not "files". Any idea how to fix it?