使用Cordova文件插件或相机插件上传Cordova图像

问题描述

我正在处理Cordova文件上传。众所周知,Cordova插件文件传输已贬值。我找不到任何参考代码作为完整的示例。根据

window.requestFileSystem(LocalFileSystem.PERSISTENT,function (fs) {
    console.log('file system open: ' + fs.name);
    fs.root.getFile('bot.png',{ create: true,exclusive: false },function (fileEntry) {
        fileEntry.file(function (file) {
            var reader = new FileReader();
            reader.onloadend = function() {
                // Create a blob based on the FileReader "result",which we asked to be retrieved as an ArrayBuffer
                var blob = new Blob([new Uint8Array(this.result)],{ type: "image/png" });
                var oReq = new XMLHttpRequest();
                oReq.open("POST","http://mysweeturl.com/upload_handler",true);
                oReq.onload = function (oEvent) {
                    // all done!
                };
                // Pass the blob in to XHR's send method
                oReq.send(blob);
            };
            // Read the file as an ArrayBuffer
            reader.readAsArrayBuffer(file);
        },function (err) { console.error('error getting fileentry file!' + err); });
    },function (err) { console.error('error getting file! ' + err); });
},function (err) { console.error('error getting persistent fs! ' + err); });

我试图做到这一点,但是与服务器没有连接。如何将图像文件上传到目标PHP链接

顺便说一句,如果您可以用sudo代码说明PHP方面,我将非常高兴。除了用于创建特殊的上传文件夹之外,我还有一个参数log_uid,用于通过此图像上传发送到PHP

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)