- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Good morning everyone
I m working on a iphone mobile application where i need to record audio and send the audio file to my server
I work with the "phonegap audio" intel xdk demo provided with the xdk software and when i try to upload the audio file after record
> i have always the same error message > "ERROR uploading file Cannot find the file for upload"
I've tried many differents solutions :
> i use intel.xdk.file.uploadToServer function and it work for the pictures files but not for the audio
> i use the media type > audio/x-wav to upload
> i v tried to add "intel.xdk.webRoot" to my source path audio file but its dont help
> i have tried other types of audio demos based on cordova but no one worked > i have other errors of audio recording
Here is my javascript upload code:
var url= intel.xdk.webRoot+audioFileUrl
intel.xdk.file.uploadToServer(url,serverRoot+"mobileTools/upload.php", "", "audio/x-wav", "updateUploadProgress");
The PHP
<?php
ob_start();
echo "<pre>";
print_r($_FILES);
print_r($_GET);
print_r($_POST);
echo "</pre>";
print_r("file type: " . $_FILES["Filedata"]["type"]);
$allowedExts = array("gif", "jpeg", "jpg", "png");
$temp = explode(".", $_FILES["Filedata"]["name"]);
$extension = end($temp);
if ((($_FILES["Filedata"]["type"] == "image/gif")
|| ($_FILES["Filedata"]["type"] == "image/jpeg")
|| ($_FILES["Filedata"]["type"] == "image/jpg")
|| ($_FILES["Filedata"]["type"] == "image/pjpeg")
|| ($_FILES["Filedata"]["type"] == "image/x-png")
|| ($_FILES["Filedata"]["type"] == "image/png"))
&& ($_FILES["Filedata"]["size"] < 9999999999)
&& in_array($extension, $allowedExts))
{
if ($_FILES["Filedata"]["error"] > 0)
{
echo "Return Code: " . $_FILES["Filedata"]["error"] . "<br>";
}
else
{
echo "uploads: " . $_FILES["Filedata"]["name"] . "<br>";
echo "Type: " . $_FILES["Filedata"]["type"] . "<br>";
echo "Size: " . ($_FILES["Filedata"]["size"] / 1024) . " kB<br>";
echo "Temp file: " . $_FILES["Filedata"]["tmp_name"] . "<br>";
if (file_exists("uploads/" . $_FILES["Filedata"]["name"]))
{
echo $_FILES["Filedata"]["name"] . " already exists. ";
}
else
{
move_uploaded_file($_FILES["Filedata"]["tmp_name"],
"uploads/" . $_FILES["Filedata"]["name"]);
echo "Stored in: " . "uploads/" . $_FILES["Filedata"]["name"];
}
}
}
else
{
echo "Invalid file";
}
$data=ob_get_clean();
$fp=fopen("debug.txt","w+");
fputs($fp,$data);
fclose($fp);
?>
I work on the last version of iphone app preview 2.3.3 and the last PC xdk software version
I you have some help this can save my life :)
Thanks you
- Tags:
- HTML5
- Intel® XDK
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
If it cannot find the file for uploading, you might be having trouble accessing the root directory on your device.
Please refer to this stackoverflow posting: http://stackoverflow.com/questions/21321335/intel-xdk-directory-browsing
The second answer by xmnboy should give you a clue on how to go about this.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page