Read application/X-www-form-urlencoded data from Angular 2 in express #796
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
We've got a function which calls an API to upload files + normal form data a.k.a. strings
And the template like:
The code
this.formData['logoUrl'] = this.uploader.queue[0];gives the reference of the file being uploaded, however on the server side:The value of
req.body.logoUrlis coming as undefined.original reference
Multer's documentation says that you can read the file data through
req.files, notreq.body. Did you try that?If you are uploading a single file (
upload.single), you can access it throughreq.file, andreq.file.locationwill give you the location of the uploaded file.If you are uploading multiple files at once (
upload.array), you can access it usingreq.files.req.filesis an array, soreq.files[i].locationshould give you the url (Not sure about it though), just check it.But , in your case, you should try
req.file.location.How it will work if we have Python as a backend. I am only getting the file object, not getting file binary data. SO how I will do that in python?
Can you tell more about the object that you are getting in the backend. How are you uploading the file in the server???
Frontend Code
I am getting multipart/form-data at the backend, but when I am uploading it to s3 then the whole image comes black when viewed
How are you reading multi-part form data at the backend?