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

Invalid bundle error while upload the app to the app Store

Saved Image in document directory and save path in coredata not able to fetch the image file iOS swift