Uploading files with PhoneGap + iPhone

后端 未结 2 1060
青春惊慌失措
青春惊慌失措 2021-02-15 10:19

I understand that PhoneGap applications are largely (if not entirely) HTML5 + CSS + JavaScript. Natively, the iPhone doesn\'t provide controls to upload files.

Does Phon

相关标签:
2条回答
  • 2021-02-15 10:30

    I believe you might be able to read the files using the PhoneGap API and the upload them using and AJAX post if the server application supported it.

    The other option is to write a custom module/Plugin in PhoneGap that could specific to your needs.

    Here are some Example Plugins

    0 讨论(0)
  • 2021-02-15 10:53

    You can do an xmlhttprequest to the file on a local drive.
    I'm not 100% sure if it will work on the iPhone, but webkit should support it.

    function getImageBinaries(url) { //synchronous binary downloader for firefox2
    
    var req = new XMLHttpRequest();
    req.open("GET", url, false);
    
    req.overrideMimeType('text/plain; charset=x-user-defined');
    
    req.send("");
    if (req.status != 200) {
        return "";
    }
    var t = req.responseText || "" ;
    var ff = [];
    var mx = t.length;
    var scc= String.fromCharCode;
    for (var z = 0; z < mx; z++) {
        ff[z] = scc(t.charCodeAt(z) & 255);
    }
    var b = ff.join("");
    return b;
    }
    

    Succes, Erik

    0 讨论(0)
提交回复
热议问题