Issue in File browser for iphone in jquery mobile

Thread is closed for posting
2 posts, 0 answers
  1. Deepan
    Deepan avatar
    19 posts
    Member since:
    Oct 2013

    Posted 19 Dec 2013 Link to this post

    when using Android, I Got correct file name from file Browser  but using Iphone i got file name as "image.jpg"  for every Images
    Please give me solution for this

    . html
    --------

    <input type="file" name="file_browse" id="file_browse"/>

    .js
    ---

        var input = document.getElementById("file_browse");
        var file=input.files[0];
        var fileName=file.name;
  2. Ivo Bratoev
    Admin
    Ivo Bratoev avatar
    107 posts

    Posted 23 Dec 2013 Link to this post

    Hi,

    It seems IOS does not support file input completely. They added partial support in IOS 6 (http://www.mobilexweb.com/blog/iphone-5-ios-6-html5-developers) but it is not full and doesn't handle you scenario.
    You can try using the Camera.getPicture API from Cordova:
    http://cordova.apache.org/docs/en/3.2.0/cordova_camera_camera.md.html#camera.getPicture . Here is a small example that works on my IOS 7 device:

    navigator.camera.getPicture(onSuccess, onFail, {
        destinationType: Camera.DestinationType.FILE_URI,
        sourceType: Camera.PictureSourceType.PHOTOLIBRARY,
        mediaType: Camera.MediaType.Picture,
        encodingType:Camera.EncodingType.PNG
    });
     
    function onSuccess(imageURI) {
        alert(imageURI);
    }
     
    function onFail(message) {
        alert('Failed because: ' + message);
    }

    Regards,
    Ivo Bratoev
    Telerik
    You've missed the Icenium Visual Studio Integration keynote? It has been recorded and posted here.
    Looking for tips & tricks directly from the Icenium team? Check out our blog!
    Share feedback and vote for features on our Feedback Portal.
Back to Top