open document picker and upload iOS swift

 Solution:

var selectedDocPath: URL!

extension docVC: UIDocumentPickerDelegate {

    func documentPicker(_ controller: UIDocumentPickerViewController, didPickDocumentsAt urls: [URL]) {

        // Handle the selected PDF file here

        let selectedURL = urls.first

        selectedDocPath = selectedURL

        uploadDoc()

        // Process the selected PDF file

    }

    

    func documentPickerWasCancelled(_ controller: UIDocumentPickerViewController) {

        // Handle cancellation

    }

}



Use selectedDocPath to upload the file to server

Comments

Popular posts from this blog

store cgpoint in userdefaults iOS swift

libc++abi: terminating due to uncaught exception of type NSException iOS swift