I am using angularjs.I am getting zip file URL from the server.
I am using below code to download my file.
Example 1
Filename comes from the angular controller.
From the above code I will be able to download the file but in the download folder.How can I download that file in specified location ?
just open that link in new tab it will automatically be download.
window.open(wholeURLToDownload);
Related
I'm trying to download a sample xlsx file from public folder in React js in the following way
<a
href={process.env.PUBLIC_URL + "/my-file.xlsx"}
download={"my-file.xlsx"}
>
Download file
</a>
i am stuck at this. downloading this way works locally, but when deployed to public, it fails and instead downloads just an empty corrupted file. Any ideas on that ?
Why the file is being corrupted on the server, although it works fine locally?
you should use relative path of file for href,
ex: href={"../../assets/files/my-file.xlsx"}
and dont do this "download={"my-file.xlsx"}"
instead write download={true} or only download
This is what I implemented:
downloadFile=(file)=>{
var element=document.createElement('a');
element.style.display= "none";
element.setAttribute('href', file.fileUrl)
element.setAttribute("target", "_blank");
document.body.appendChild(element)
element.click()
document.body.removeChild(element)
}
This is working fine for .ai files but not for .pdf or .jpeg. Instead of downloading the file, the browser opens it in a separate window. I want to enable download file feature and not open file. How do I fix this issue? Is there an alternative way to download the file from url from browser?
Try to use download attribute instead of href.
See element a DOC.
I'm creating an app with ionicframework. I want that the user can downolad pdf files which are in the app. In which folder i must place the files, in template folder? How can the user download the files, i must use < a ui-sref="file.pdf" >< /a >?
Thank you.
If your PDF files are in the application, you could save them in temporary filesystem and after open with default app (move them).
To get access to the device’s files and directories, you need work with plugin $cordovaFile (http://ngcordova.com/docs/plugins/file/). Here you will find the file system layout.
To open a file on your device with its default application use $cordovaFileOpener2 (http://ngcordova.com/docs/plugins/fileOpener2/)
I'm trying don't move file.
I used InAppBrowser plugin (in ionic 2 project) and i have a 'a.pdf' file in 'www' folder. i use this code:
In .js file:
> openURL(url) {
> InAppBrowser.open(url,'_system','location=yes'); }
In .html file:
<button (click)="openURL('a.pdf')">Open pdf
</button>
When i press on button the device ask me to select a program to open file, then i select adobe reader pdf. But adobe reader pdf tells me 'impossible to load file ...'.
What is the right path (url) to call openURL(url)?
Thank you.
I am developing an app for ipad using
ionic framework
I am stuck at one point were
i want to open a PDF file using inappbrowser from an local folder
So that the user can read the PDF internally. The PDF is kept in local folder were my HTML file is available and i am trying to open it through below code:
window.open('pdf-sample.pdf', '_blank', 'location=yes');
But the issue is when i am trying to open it i am
not able to view/read the PDF file
It shows me the white blank screen with no content in it.
Screenshot:
What should i do to resolve this issue?
-thanks
The code looks ok. Try to open https://www.google.com/. If that works than the path to pdf is not correct.
Are you sure you try to open after deviceready ?
I have PDF file located in the local file system,
local file path:
C:\pdf\sample.pdf
How do i open the pdf file in the browser using angularjs.
I hope it may help just follow the instructions and there is an example in the zip file try it.
http://ngmodules.org/modules/ng-pdfviewer