I am trying to upload document using documentpicker. I am able to browse the document from my phone document folder but after choosing nothing is happen. I want to get that document like (sample.text or sample.pdf) and upload it to my database server.
Here is my code:
@IBAction func bio_choose_document_btn(_ sender: Any)
{
let importDocument = UIDocumentPickerViewController(documentTypes: [String(kUTTypePDF), String(kUTTypePlainText), String(kUTTypeJPEG), String(kUTTypePNG)], in: .import)
importDocument.delegate = self
importDocument.allowsMultipleSelection = true
importDocument.modalPresentationStyle = .formSheet
self.present(importDocument, animated: true, completion: nil)
}
public func documentPicker(_ controller: UIDocumentPickerViewController, didPickDocumentsAt urls: [URL]) {
guard let filepathurl = urls.first
else {
return
}
let fileName = filepathurl.lastPathComponent
bio_no_file_choosen_lbl.text = fileName
doc_webview.load(URLRequest(url: filepathurl))
//let items = TableViewItem()
//items?.documentname = self.bio_doc_view.text
//self.TableView_item.append(items!)
print("import result : (filepathurl)")
self.bio_documentview_tvc.reloadData()
}
public func documentMenu(_ documentMenu:UIDocumentPickerViewController, didPickDocumentPicker documentPicker: UIDocumentPickerViewController) {
documentPicker.delegate = self
present(documentPicker, animated: true, completion: nil)
}
func documentPickerWasCancelled(_ controller: UIDocumentPickerViewController) {
print("view was cancelled")
dismiss(animated: true, completion: nil)
}
I am using webview but it opens the whole document as a view. I don't want to open it. I want to retrieve the document as a folder.
Any help will be highly appreciated.
Thank You!
Rutuparna Panda