0
我得到下面的錯誤:從Android的上傳圖片到ASP.NET
Cannot process the message because the content type
'multipart/form-data;
boundary=0JxmnFLOmjvutAKrtR1bmPCqpG8M6WbwE-aAvh8' was not the expected
type 'text/xml; charset=utf-8'
的Android代碼:
HttpPost httppost = new HttpPost("http://192.168.9.103/AndroidService/MediaUploadService.svc/uploadFile1");
File photo = new File(Environment.getExternalStorageDirectory(), "01.jpg");
MultipartEntity t = new MultipartEntity();
t.addPart("t", new FileBody(photo));
httppost.setEntity(t);
HttpClient httpclient = new DefaultHttpClient();
HttpResponse response = httpclient.execute(httppost);
WCF代碼:
public class MediaUploadService : IMediaUploadService
{
public void UploadFile(Stream fileContents)
{
byte[] buffer = new byte[10000];
int bytesRead, totalBytesRead = 0;
do
{
bytesRead = fileContents.Read(buffer, 0, buffer.Length);
totalBytesRead += bytesRead;
} while (bytesRead > 0);
File.WriteAllText(@"D:\\Vechile\log2.txt", totalBytesRead.ToString());
}
}
有人能幫我做這個過程嗎?
我的問題: -
必須從Android上傳圖片文件到服務器(通過IIS - >的.asp,的.asmx,.SVC等)
可以在任何一個建議我在這個問題上?