Uploading files with PhoneGap + iPhone

后端 未结 2 1072
青春惊慌失措
青春惊慌失措 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: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

提交回复
热议问题