2013-08-23 98 views
-1

任何人都可以告訴我,這段代碼有什麼問題,它返回語法錯誤的錯誤。任何人都可以修復它?這段代碼有什麼問題,它給出了錯誤

dos.writeBytes(twoHyphens + boundary + lineEnd); 
dos.writeBytes("Content-Disposition: form-data; name="uploaded_file";filename="" 
+ fileName + """ + lineEnd);' 

和它的第二部分在捕獲它會返回錯誤。檢查這一項,請:

runOnUiThread(new Runnable() { 
public void run() { 
String msg = "File Upload Completed.\n\n See uploaded file here : \n\n" 
      +http://www.androidexample.com/media/uploads/" 
      +uploadFileName; 
messageText.setText(msg); 
Toast.makeText(UploadToServer.this, "File Upload Complete.",Toast.LENGTH_SHORT).show(); 
     } 
    });     
    }  
fileInputStream.close(); 
dos.flush(); 
dos.close(); 
} catch (MalformedURLException ex) { 
    dialog.dismiss(); 
    ex.printStackTrace(); 
runOnUiThread(new Runnable() { 
public void run() { 
messageText.setText("MalformedURLException Exception : check script url."); 
Toast.makeText(UploadToServer.this, "MalformedURLException",Toast.LENGTH_SHORT).show(); 

} 
}); 
Log.e("Upload file to server", "error: " + ex.getMessage(), ex); 
} catch (Exception e) { 
dialog.dismiss(); 
e.printStackTrace(); 
runOnUiThread(new Runnable() { 
public void run() { 
    messageText.setText("Got Exception : see logcat "); 
    Toast.makeText(UploadToServer.this, "Got Exception : see logcat ",Toast.LENGTH_SHORT).show(); 
    }}); 
Log.e("Upload file to server Exception", "Exception : " + e.getMessage(), e); 
    } 
    dialog.dismiss();  
    return serverResponseCode;    
} // End else block 
} 
} 
@Override 
public boolean onCreateOptionsMenu(Menu menu) { 
getMenuInflater().inflate(R.menu.upload_to_server, menu); 
return true; 
} 
} 
+1

是否錯誤消息給出的語法錯誤的行號?這應該可以幫助您確切地確定哪個部分是問題。 –

+1

有史以來最好的問題...; /下一次嘗試更具體的說法! –

+0

當您下次發佈問題時,請妥善格式化您的代碼。 – Raghunandan

回答

0
dos.writeBytes("Content-Disposition: form-data; name=\"uploaded_file\";\"filename=\""+ fileName + "\"" + lineEnd); 

雙qoutes沒有雙qoutes內使用,你需要把「\」(反斜線)