TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
ahmed elbarbary
NA
1.6k
275.3k
File not downloaded as attachement on browser although api return file
Nov 24 2020 6:03 AM
I work on asp.net core 2.2 web api project with angular 7 .
my issue on when click on upload button
File not download as attachment on browser .
when put break point on api and run angular app it hitted break point and file name can see from api when pass it
I think this is problem of angular 7 because web api return file
on angular 7
on angular 7
component.ts
fileToUpload:
File
=
null
;
public
uploadFile
= (files) =
>
{
const
formData
=
new
FormData();
formData.append('file', this.fileToUpload,this.fileToUpload.name);
this.http.post('https://localhost:44396/api/ApprovalQuality/', formData)
.subscribe(
data
=
>
{
},
error
=
>
{
console.log(error);
});
}
handleFileInput(files: FileList) {
if (
files.length
== 0) {
return;
}
this.fileToUpload
=
files
.item(0);
console.log(this.fileToUpload)
}
component.html
<
button
type
=
"button"
class
=
"btn btn-success"
(click)="uploadFile(files)"
>
Upload Filebutton
>
test api return like that by post man give me 200 Status OK
but on browser no file download as result
when connect angular 7 with api no file returned and no file downloaded
so How to solve issue
Reply
Answers (
2
)
error on event.total object possibly is undefined when Upload file?
display list of images in layout using typescript and HTML