У меня возникает много проблем с загрузкой файлов на сервер в Titanium appcelerator. Кажется, все работает нормально, но на сервере он показывает, что произошла ошибка. Вот мой титановый код:Titanium Appcelerator загружает изображения на веб-сервер
var win = Ti.UI.createWindow({
backgroundColor : "#FFF"
});
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();
win.open();
Titanium.Media.openPhotoGallery({
success : function(event) {
alert("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://mypathtotheserver/myphpuploaderfile.php');
xhr.setRequestHeader("Connection", "close");
// send the data
xhr.send({
media : image
});
},
cancel : function() {
},
error : function(error) {
},
allowImageEditing : true
});
и код PHP на сервере:
$target_path = "uploads/";
$target_path = $target_path . $_FILES['media']['name'];
if(move_uploaded_file($_FILES['media']['tmp_name'],$target_path)) {
echo "The file ". basename($_FILES['media']['name']).
" has been uploaded";
}
else
{
echo "There was an error uploading the file, please try again!";
}
Что я делаю неправильно? Любая помощь высоко ценится.
Спасибо заранее!
привет, работающий на iOS, но не работающий на Android? ват делать? любое предложение – joe