Issue with uploading recorded sound file to server

Showing 1-2 of 2 messages
Issue with uploading recorded sound file to server Rune Lyngbach Jensen 5/30/13 4:21 AM
Having some extensive problems with uploading my recorded file to my server.

Using phonegap's record and fileTransfer API.

The recording works like a charm without any errors and I have even set up a small playback/stop function within the app that are also working beautiful.

However upon sending the recorded sound to the server it seems like it doesnt send everything and the file gets corrupted/not working like there is nothing in it.

this is my upload funktion:

function uploadFile() {
                var fileURI = 'file:///mnt/sdcard/myrecording.wav';
               
                var options = new FileUploadOptions();
                options.fileKey = "file";
                options.fileName = fileURI.substr(fileURI.lastIndexOf('/')+1);
                console.log(options.fileName);
                options.mimeType = "audio/wav";
               
                var params = {};
                params.value1 = "test";
                params.value2 = "param";
               
                options.params = params;
               
                var ft = new FileTransfer();           
                ft.upload(fileURI, encodeURI("http://mydomain.com/app/upload.php"), win, fail, options);
               
               
                function win(r) {
                    console.log("Code = " + r.responseCode);
                    console.log("Response = " + r.response);
                    console.log("Sent = " + r.bytesSent);
                }
       
                function fail(error) {
                    alert("An error has occurred: Code = " + error.code);
                    console.log("upload error source " + error.source);
                    console.log("upload error target " + error.target);
                }
}


The logcat gives back code 200 which I believe stands for success? I do a simple print_r($_FILES) on my php script so I can see the size of the file.

The bytes sent however is significant lower than the actually file size (according to this array print).


Tried both with and without the encodeURI, made sure my allow_url_fopen is set to true, allowed upload size is way beyond enough.

Started with .mp3 exension then learned later that Android doesn't complain about this however is not working correctly with this format (the record and playback was still working on the app tho). Also tried with .amr and are now just using .wav to make sure its not an extention problem.
I have read somewhere that the Phonegap might be sending/adding some data in front of the sound file, which fucks it all up, however I have no clue how to check for this nor what to do, to solve that. Also curious, if that's the case, why is it still sending less then the actually file size? shouldn't it be more then?


Really lost here and hope someone can help.


Regards
Rune

Re: Issue with uploading recorded sound file to server 包四維 7/31/13 8:04 AM
The code can completly help you
although it is capture function,but the file upload function is the same

although it is capture function,but the file upload function is the same

Rune Lyngbach Jensen於 2013年5月30日星期四UTC+8下午7時21分06秒寫道: