1

Phonegap を使用して音声ファイルをアップロードしようとしていますが、応答コード 200 が返され続け、サーバーにファイルが表示されません。サーバーは共有サーバーであるため、サーバーへのリモートアクセスしかありません。

どんな助けでも大歓迎です。

ありがとう。

これが私のPhonegapコードです

uploadSound("filename.amr", 'Test/Recorded', "audio/AMR", 'http://test.com/share.php');

function uploadSound(fileName, dirName, fileMime, uploadURL) {

     var win = function (r) {
         console.log("Code = " + r.responseCode);
         console.log("Response = " + r.response);
         console.log("Sent = " + r.bytesSent);
     };

     var fail = function(error) {
         alert("An error has occurred: Code = " + error.code);
     };

     // file system fail
     var fsFail = function(error) {
         alert("failed with error code: " + error.code);

     };

     var dirFail = function(error) {
         alert("Directory error code: " + error.code);

     };

     var fileURI;

     var gotFileSystem = function (fileSystem) {
         fileSystem.root.getDirectory(dirName, {
            create: false
         }, function (dataDir) {

            fileURI = dataDir.fullPath;
            fileURI = fileURI + '/' + fileName;

            var options = new FileUploadOptions();
            options.fileKey = "file";
            options.fileName = fileURI.substr(fileURI.lastIndexOf('/') + 1);
            options.mimeType = fileMime;

            var params = new Object();
            params.action = "save";
            params.name = fileName;

            options.params = params;

           var ft = new FileTransfer();
           ft.upload(fileURI, uploadURL, win, fail, options);

        }, dirFail);

   };
// get file system to copy or move image file to
window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, gotFileSystem, fsFail);

                                    }

ここに私のPHPコードがあります

print_r($_FILES);
$new_image_name = $name;
move_uploaded_file($_FILES["file"]["tmp_name"], $_SERVER['DOCUMENT_ROOT'] . "/Shared/" . $new_image_name);

ここにログがあります

07-27 16:15:42.789: D/WindowManagerImpl(4931): addView, new view, mViews[1]: com.android.internal.policy.impl.PhoneWindow$DecorView@405e17b8
07-27 16:15:43.740: D/View(4931): onTouchEvent: viewFlags: 0x18004001
07-27 16:15:43.740: D/View(4931): onTouchEvent: isFocusable: true, isFocusableInTouchMode: false, isFocused: false; focusTaken: false
07-27 16:15:43.740: D/WindowManagerImpl(4931): finishRemoveViewLocked, mViews[1]: com.android.internal.policy.impl.PhoneWindow$DecorView@405e17b8
07-27 16:15:43.810: D/FileTransfer(4931): upload file:///mnt/sdcard/Test/testsound.amr to http://test.com/share.php
07-27 16:15:43.810: D/FileTransfer(4931): fileKey: file
07-27 16:15:43.810: D/FileTransfer(4931): fileName: testsound.amr
07-27 16:15:43.810: D/FileTransfer(4931): mimeType: audio/AMR
07-27 16:15:43.810: D/FileTransfer(4931): params: {"action":"save","name":"testsound.amr"}
07-27 16:15:43.810: D/FileTransfer(4931): trustEveryone: false
07-27 16:15:43.810: D/FileTransfer(4931): chunkedMode: true
07-27 16:15:43.810: D/FileTransfer(4931): headers: null
07-27 16:15:43.820: D/FileTransfer(4931): objectId: 1
07-27 16:15:43.830: D/webcore(4931): [WebViewCore::handleMessage] handle msg=[3::1] over 1 sec. (1173.0)
07-27 16:15:43.850: D/FileTransfer(4931): Content Length: 8547
07-27 16:15:43.971: D/FileTransfer(4931): Sent 8547 of 8547
07-27 16:15:44.231: D/FileTransfer(4931): response code: 200
07-27 16:15:44.241: D/FileTransfer(4931): response headers: {Connection=[Keep-Alive], Content-Type=[text/html], Date=[Sat, 27 Jul 2013 23:15:42 GMT], Keep-Alive=[timeout=15, max=100], Server=[Apache], Transfer-Encoding=[chunked]}
07-27 16:15:44.241: D/FileTransfer(4931): got response from server
07-27 16:15:44.241: D/FileTransfer(4931):  
07-27 16:15:44.251: D/CordovaLog(4931): Code = 200
07-27 16:15:44.251: I/Web Console(4931): Code = 200 at file:///android_asset/www/js/test.js:772
07-27 16:15:44.251: D/CordovaLog(4931): Response = 
07-27 16:15:44.251: D/CordovaLog(4931):  
07-27 16:15:44.251: I/Web Console(4931): Response = 
07-27 16:15:44.251: I/Web Console(4931):   at file:///android_asset/www/js/test.js:773
07-27 16:15:44.261: D/CordovaLog(4931): Sent = 278
07-27 16:15:44.261: I/Web Console(4931): Sent = 278 at file:///android_asset/www/js/test.js:774
07-27 16:16:05.892: D/DroidGap(4931): Paused the application!
4

0 に答える 0