Search code examples
iosobjective-cuiimagepickercontroller

Add a file into the ios app


I am a newbie to iOS, I have a created a textfield and imageView in a ViewController. I want user of app to select an image or a file(.txt,.csv, etc)into the App. I know that Apple provides UIImagePicker to select images from the device. with these I added an image to my imageView.

Now I want to Know that is there any way to select files from the device and use it into application. Or else Open file system of device and select the file ?

When I Googled it, I got that you are not able to open the file system. So how can I implement this functionality in iOS app?


Solution

  • There is no way of selecting file from file system into application. You can only access files from

    1. Default Photos App
    2. Application Documents Directory
    3. Any file from web server with use of API's

    There are multiple ways from which you can select files of different types other than images are

    1. Integrate Dropbox SDK into app
    2. Integrate Google Drive
    3. Integrate iCloud

    So create one UIButton like "Select File" and open UIActionSheet on tap of it. UIActionSheet will have options like

    1. Select From Photos
    2. Select File From Dropbox
    3. Select File From iCloud
    4. Select File From Google Drive etc

    And you can call respective actions on each index.