2013-06-05 65 views
0

我試圖發送一個圖片,採取我的應用程序,到我的遠程服務器使用JavaScript和PHP,但到目前爲止,米卡住:我試圖發送wp8上的phonegap圖片,但我得到一個錯誤

這是

function onPhotoDataSuccess(imageData) { 
    alert(imageData);// returns:"/CapturedImagesCache/WP_20130605_021.jpg" 
    //send picture to server 
    var options = new FileUploadOptions(); 
    options.fileKey="file"; 
    options.fileName=imageData.substr(imageData.lastIndexOf('/')+1); 
    options.mimeType="image/jpeg"; 

    var params = new Object(); 
    params.value1 = "test"; 
    params.value2 = "param"; 

    options.params = params; 

    var ft = new FileTransfer(); 
    ft.upload(imageData, "http://***.**/app/upload/upload.php", win, fail, options); 
    alert ("picture will be send"); 
} 

PHP的服務器正在運行從我的應用程序的代碼:

$new_image_name = "YEAH.jpg"; 
move_uploaded_file($_FILES["file"]["tmp_name"],"/httpdocs/app/upload/images/".$new_image_name); 

這是我得到的錯誤:

Log:"Error in error callback: FileTransfer1933815797 = ReferenceError: Invalid left-hand side in assignment"

我真的很希望任何人都有這方面的經驗,因爲這是爲期兩週的學校項目。

回答

0

我發現的問題是,我打電話到一個chache位置,由於這個事實,我無法用ajax發送圖像。

我解決這個問題的方式是根本不發送圖像,我使用base64編碼將其粘貼到畫布中,以便我能夠從圖像中獲得平均顏色,然後我可以發送值給我的服務器。

我會盡快添加我的代碼片段

相關問題