最終的には、Titanium Mobile を使用して iPhone アプリを開発することになりました。今私が直面している問題は、アプリを実行でき、アプリも画像をサーバーに送信することです。しかし、サーバーにアップロードされたファイルを見ることができません。画像をサーバーに送信する iPhone アプリのコードと、アプリからファイルを受信する PHP ファイルを貼り付けました。
var win = Titanium.UI.currentWindow;
var ind=Titanium.UI.createProgressBar({
width:200,
height:50,
min:0,
max:1,
value:0,
style:Titanium.UI.iPhone.ProgressBarStyle.PLAIN,
top:10,
message:'Uploading Image',
font:{fontSize:12, fontWeight:'bold'},
color:'#888'
});
win.add(ind);
ind.show();
Titanium.Media.openPhotoGallery({
success:function(event)
{
Ti.API.info("success! event: " + JSON.stringify(event));
var image = event.media;
var xhr = Titanium.Network.createHTTPClient();
xhr.onerror = function(e)
{
Ti.API.info('IN ERROR ' + e.error);
};
xhr.onload = function()
{
Ti.API.info('IN ONLOAD ' + this.status + ' readyState ' + this.readyState);
};
xhr.onsendstream = function(e)
{
ind.value = e.progress ;
Ti.API.info('ONSENDSTREAM - PROGRESS: ' + e.progress+' '+this.status+' '+this.readyState);
};
// open the client
xhr.open('POST','http://www.myserver.com/tmp/upload2.php');
xhr.setRequestHeader("Connection", "close");
// send the data
xhr.send({media:image});
},
cancel:function()
{
},
error:function(error)
{
},
allowImageEditing:true
});
サーバー上の PHP コードは次のとおりです: http://www.pastie.org/891050
どこが間違っているのかわかりません。この問題で私を助けてください。さらに情報が必要な場合は、提供したいと思います。