IONIC 3-从文件管理器中选择时,我想获取pdf的文件路径 [英] IONIC 3 - I want to get file path of the pdf when select from file manager
本文介绍了IONIC 3-从文件管理器中选择时,我想获取pdf的文件路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在这里,我要发布我从文件管理器中选择PDF的代码.我需要获取所选PDF的文件路径.我怎么能得到它?
Here i am posting my code of selecting PDF from file manager. i need to get file path of selected PDF. how can i get it?
.html
<input type="file" (change)="selectPDF($event)" class="file-input upload-items" name='company_pdf' style="opacity: 0"
id="company_pdf" #fileInp>
.ts
selectPDF(fileInput: any) {
if (fileInput.target.files[0].type == 'application/pdf') {
console.log(fileInput.target.files)
this.PDFfiles.push(fileInput.target.files[0]);
if (this.PDFfiles.length > 4) {
this.disablePdfUplaod = true;
}
//this.PDFfile = fileInput.target.files[0];
} else {
this.shared.showToast('Please select PDF')
}
}
推荐答案
在这里您可以找到android和iOS平台的答案.如何选择pdf文档并查看该文档.
Here you can find both android and iOS platform answer. How to pick pdf document and view that document.
.html
<input (click)="openFile()" class="file-input upload-items" name='company_pdf' style="opacity: 0"
id="company_pdf" >
.ts
openFile() {
if (this.platform.is('android')) {
this.fileChooser.open()
.then(
uri => {
this.filePath.resolveNativePath(uri)
.then(url => {
console.log(url)
// url is path of selected file
var fileName = url.substring(url.lastIndexOf("/") + 1)
console.log(fileName)
// fileName is selected file name
})
.catch(err => console.log(err));
}
)
.catch(error => {
console.log(error)
});
} else {
this.docPicker.getFile('pdf')
.then(uri => {
console.log(uri)
var fileName = uri.substring(uri.lastIndexOf("/") + 1)
})
.catch(e => console.log(e));
}
}
希望它会对您有所帮助.
Hope it will helps you.
这篇关于IONIC 3-从文件管理器中选择时,我想获取pdf的文件路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文