Software Archive
Read-only legacy content
Announcements
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.
17060 Discussions

Xdk audio record and upload do not work

Claude_M_
Beginner
574 Views


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 

 


    

 

0 Kudos
2 Replies
Anusha_M_Intel1
Employee
574 Views

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. 

0 Kudos
PaulF_IntelCorp
Employee
574 Views

Here's a direct link to the answer Anusha is refering to: http://stackoverflow.com/a/21392617

0 Kudos
Reply