-
-
Save jonalter/7375507 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Titanium.Media.openPhotoGallery({ | |
success:function(event){ | |
var myImage = event.media; | |
var xhr = Titanium.Network.createHTTPClient(); | |
xhr.open('POST','http:// ------ /uploads.php'); | |
xhr.onerror = function(e){alert(e.error);}; | |
xhr.setTimeout(200000); | |
xhr.onload = function(e){ | |
Ti.UI.createAlertDialog({title:'Success', message: this.responseText | |
}).show();}; | |
xhr.onsendstream = function(e){Ti.API.info(e);}; | |
xhr.setRequestHeader("contentType", "multipart/form-data"); | |
xhr.send({uploadedfile:myImage}); | |
}, | |
cancel:function(){ | |
}, | |
error:function(error){ | |
}, | |
mediaTypes:[Ti.Media.MEDIA_TYPE_VIDEO,Ti.Media.MEDIA_TYPE_PHOTO] | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$target_path = "uploads/"; | |
$target_path = $target_path . basename( $_FILES['uploadedfile']['name']); | |
if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) { | |
echo "The file ". basename( $_FILES['uploadedfile']['name'])." has been uploaded"; | |
} else{ | |
echo "There was an error uploading the file, please try again!"; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment