2013-05-13 2 views
1
내가 프로젝트에 대한 폰갭으로 장난하고있어

에 업로드 할 때 .MP3,하지만 난폰갭 파일 전송 부패 서버

내가 사용하여 MP3를 기록 할 수있어 .MP3를 업로드하는 몇 가지 문제에 봉착 장치의

var audio_name = 'fyp_app_recording_' + Math.round(new Date().getTime()/1000) + '.mp3'; 

// Record audio 
// 
function recordAudio() { 

    var src = audio_name; 
    var mediaRec = new Media(src, onSuccess(src), onError); 

    // Record audio 
    mediaRec.startRecord(); 

    // Stop recording after 10 sec 
    var recTime = 0; 
    var recInterval = setInterval(function() { 
     recTime = recTime + 1; 
     setAudioPosition("Recording Audio - " + recTime + " sec"); 
     if (recTime >= 10) { 
      clearInterval(recInterval); 
      mediaRec.stopRecord(); 
      setAudioPosition("Recording Saved As " + src); 
     } 
    }, 1000); 
} 

// onSuccess Callback 
// 
function onSuccess(src) { 
    console.log("recordAudio():Audio Success" + src); 
} 

// onError Callback 
// 
function onError(error) { 
    alert('code: ' + error.code + '\n' + 
      'message: ' + error.message + '\n'); 
} 

// Set audio position 
// 
function setAudioPosition(position) { 
    document.getElementById('audio_position').innerHTML = position; 
} 

//File upload 

    function uploadAudio() {  

     var options = new FileUploadOptions(); 
     options.fileKey="file"; 
     options.fileName="test.mp3"; 
     options.mimeType="audio/mpeg"; 

     var ft = new FileTransfer(); 
     ft.upload("mnt/sdcard/" + audio_name, "http://www.richardsonweb.co.uk/fyp/test1/upload.php", win, fail, options); 
    } 

    function win() { 
     alert("Yay! It worked!"); 
    } 

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

upload.php로 파일에 다음 코드를 포함 : 그러나

print_r($_FILES); 



$new_file_name = time() . ".mp3"; 
move_uploaded_file($_FILES["file"]["tmp_name"], "upload/".$new_file_name); 

을, 나는 다음 downloa 내장 마이크, 나는 다음 자바 스크립트를 사용하여 파일을 업로드 할 수 있어요 파일을 내 FTP 클라이언트에서 가져온 경우 Windows Media Player에서 파일이 손상되었다고 주장합니다.

이상하게도 파일 정렬은 VLC에서 잘 작동합니다 (진행 막대가 10 초에 멈추고 움직이지 않지만 오디오는 완벽하게 재생됩니다).

왜 이런 일이 일어날 수 있으리라 생각하십니까? 미리 감사드립니다!

답변

2

은 도움이 PHP 코드를

<?php 
    $destination_path = getcwd().DIRECTORY_SEPARATOR; 

    $result = 0; 

    $target_path = $destination_path . time() . ".mp3"; 

    ini_set("upload_max_filesize", "3200000000"); 

    if(@move_uploaded_file($_FILES['file']['tmp_name'], $target_path)) { 
     $result = 1; 
    } 

    sleep(1); 
?> 
+0

감사를 사용해보십시오 (이 여전히 서버에 파일을 이동 않습니다)하지만 어떤 이유로 파일이 여전히 손상되었습니다. 왜 이런 일이 일어날 지 모릅니다. –

+0

어쩌면 최대 파일 업로드 제한입니다. ini_set ("upload_max_filesize", "3200000000"); –

+0

@ LiamRichardson, 왜 upload_max_filesize가 문제를 해결했다고 대답 했습니까? – Ionut