I'm trying to upload some files to my website. I used this code from someone else;
var xhr = Titanium.Network.createHTTPClient();
var file = Titanium.Filesystem.getFile(Titanium.Filesystem.resourcesDirectory + 'text.txt');
Titanium.API.info(file);
var toUpload = file.read();
xhr.open('POST', 'http://www.domain.com/upload.php', false);
xhr.send({media: toUpload});
I tried to run my app with this method, it says it's done uploading, but when I look, my files are not there.
Also I used this PHP file to handle the upload;
<?php
$target = "upload/";
$target = $target . basename( $_FILES['uploaded']['name']) ;
$ok=1;
if(move_uploaded_file($_FILES['uploaded']['tmp_name'], $target))
{
echo "The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded";
}
else {
echo "Sorry, there was a problem uploading your file.";
}
?>
Is there anything wrong, or do I have to change something?
Thanks!