2013-04-27 237 views
0

我想通過形象,我參加了我的移動設備要保存在我的服務器傳輸圖像時。服務器端用php編碼。 這裏是javascript代碼:得到錯誤與PhoneGap的到PHP

var options = new FileUploadOptions(); 
         options.fileKey = "image"; 
         options.fileName = newPlace.id; 
         options.mimeType="image/jpeg"; 
         var params = new Object(); 
         params.value1 = "test"; 
         params.value2 = "param"; 

         options.params = params; 
         options.chunkedMode = false; 
         var ft = new FileTransfer(); 
         ft.upload(cameraImg, "http://www.myserver.com/upload.php", imageUploaded, imageUploadedError, options); 

服務器端代碼:

<?php 
    if(isset($_FILE['image'])) { 
     echo "good"; 
      $ourFileName = "good.txt"; 
     $ourFileHandle = fopen($ourFileName, 'w') or die("can't open file"); 
     fclose($ourFileHandle); 
     $file_name = $_FILE['image']['name']; 
     $file_tmp = $_FILE['image']['tmp_name']; 
     move_uploaded_file($file_tmp, 'images/'.$file_name); 

    } 
    else { 
     echo "not good"; 
    } 
?> 

我知道我連接到服務器和PHP代碼在運行,但它沒有趕上了`如果( isset($ _ FILE [ '圖像']))。我知道這是因爲我得到的是說「迴應:不好」的警報。我的錯誤在哪裏?提前致謝!

回答

0

那好吧,我已經改變了$_FILE$_FILES和它的工作。