【发布时间】:2013-04-10 10:18:54
【问题描述】:
我想为我的手机图库上传图片到服务器。
我已经用 iOS 设备完成了,它运行良好。但是,在 Android 设备中存在问题。
我从我的设备库中获取图像并发布到服务器上。这是上传成功。 之后我在服务器上看到。
Android 设备上传的图片,格式为 .txt。 (iOS 运行良好)。
我如何解决这个问题。请帮我向你展示我的编码结构。
Ti.API.info("success! event: " + JSON.stringify(event));
var image = event.media;
var abc = event.media.imageAsResized(400 , 400);
Ti.API.info(abc.height +" x "+ abc.width);
alert(abc.height +" x "+ abc.width);
var xhr = Titanium.Network.createHTTPClient();
xhr.onerror = function(e)
{
Ti.API.info('IN ERROR ' + e.error);
alert("error");
};
xhr.onload = function()
{
Ti.API.info('IN ONLOAD ' + this.status + ' readyState ' + xhr.responseText);
alert("IN ONLOAD " + this.status + " readyState " + this.readyState + "re " +xhr.responseText);
};
xhr.open('POST','http://reviewprototypes.com/kishan/filetest.php');
xhr.send({file:abc});
},
cancel : function() {
alert("Cancel Library ");
},
error : function(error) {
alert("Error Massage "+error);
},
allowImageEditing:true,
});
任何建议表示赞赏.. 提前致谢。
【问题讨论】:
-
我们在使用 Android 上传二进制数据时遇到了一些问题,因此我们决定使用 base64 转换所有内容并在服务器端执行相同的操作。这里的问题可能是 android 的 http 客户端和在 JavaScript 中处理二进制文件。