Click here to Skip to main content
15,881,588 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I want to show "save as" dialog box for user to storing an image from Firefox but it is not appearing. But when I open it from google chrome, I can see that box appearing.

I did my reasearch for this but could not find anything about it.

Can anyone have an idea about this? Why it is not working in Firefox but only in Chrome?

Kindly help me or suggest me something so that it will work with Firefox.

Below is my code for downloading an image.

What I have tried:

downloadOriginalImage(url: string, viewImage: boolean) {
  const imageUrl = url.replace('/jpghigh', '');
  const headers = new Headers();
  headers.append('Accept', 'application/json');
  const options = new RequestOptions({ headers: headers, responseType: ResponseContentType.ArrayBuffer });
  return this.http.get(imageUrl, options)
    .toPromise()
    .then(
      response => {
        ProduktService.extractContent(response, viewImage);
      }).catch(
        error => ProduktService.handleError(error)
      );
}

private static extractContent(res: Response, viewImage: boolean) {
  const blob: Blob = res.blob();
  const mainHead = res.headers.get('content-disposition');
  const url = window.URL.createObjectURL(blob);
  const a = document.createElement('a');
  a.href = url;
  a.download = 'image.jpg';
  a.target = '_blank';
  a.click();
  a.remove();
}
Posted
Updated 23-Apr-19 23:12pm
v2
Comments
Richard MacCutchan 24-Apr-19 4:56am    
File save options are controlled by the user, not the browser.

Go into Settings, scroll down to "Files and Applications", and click the radio button that reads "Always ask you where to save files".
 
Share this answer
 
You can't force anything to happen when you send a file to a user: the software at the client end is completely responsible for what happens, and can be set by the user to prompt, open, save, or discard the file. You as the server have no control over that whatsoever, and will never do.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900