Closed MehdiBenHamida closed 2 years ago
in the angular part use this.
URL = 'http://localhost:3000/upload'; constructor(private router:Router, private ocrService:OcrServiceService) {
this.uploader= new FileUploader({ url: this.URL});
this.uploader.onCompleteItem = (item:any, response:any, status:any, headers:any) => {
this.fileurl = response
console.log(response)
};
}
where url will the api , where you want to savesend that file for backend, and in flask
cwd = os.getcwd() dir = './uploads'
@default.route('/upload', methods=['POST', 'OPTIONS']) @crossdomain(origin='http://localhost:4200', headers='X-Requested-With,content-type') def upload(): if request.method == 'POST': file = request.files['file'] filename = secure_filename(file.filename) file.save(os.path.join(dir,filename))
where dir will the folder , where you want to save the file.
Do we know how we do upload for the flask server ?
@MehdiBenHamida Did you find any way to do this ?
@schandrakandi did you try the solution suggested by @emishaikh ?
I do not have an idea how to upload a file to Flask Python server using ng2-file-upload with Angular2. I don't know how to pass a Flask Python url to FileUploader.
I am trying to find something on internet about this, but nothing until now.
How can I develop an ng2-file-upload back-end side with Flask python?