2014-05-16 2 views
1

파일 (WebKitFormBoundary)에 추가 원치 않는 문자열 : http://hayageek.com/docs/jquery-upload-file.php오류, 나는이 플러그인을 사용하고

나는 WCF 나머지 서비스로 파일을 전송하는 데 사용하고 하드 디스크에 그것을 저장하고 있습니다를 .

업로드가 제대로 작동하지만 이미지, exe 등 문제가 있습니다. 업로드가 깨졌습니다. 내가 텍스트 편집기로 파일을 업로드 열면, 내가 볼 수있는 원치 않는 문자열

에서 시작 :

------ WebKitFormBoundaryPUTfurckDMbpBxiw 내용 - 처리를 : 폼 데이터를; name = "file"; 파일 이름 = "image.png를"콘텐츠 유형 : 이미지/PNG 끝에

:

------ WebKitFormBoundaryPUTfurckDMbpBxiw--

내 서비스 코드 :

<OperationContract()> 
<WebInvoke(ResponseFormat:=WebMessageFormat.Json, Method:="POST", UriTemplate:="GetFile?fileName={fileName}&accion={accion}")> 
Function GetFile(str As Stream, fileName As String, accion As String) As String 
    Try    
     Dim absFileName As String = "C:\inetpub\wwwroot\UploadedComponents\" & fileName 
     Using fs As New FileStream(absFileName, FileMode.Create) 
      str.CopyTo(fs) 
      str.Close() 
     End Using 
     Return "Upload OK" 
    Catch ex As Exception 
     Throw ex 
    End Try 
End Function 

어떤 아이디어로 해결할 수 있습니까?

답변

1

마지막으로 여기 해답을 발견 : 여기 Multipart Parser에서 구성 요소를 가져올 필요

Reading file input from a multipart/form-data POST

.

그리고 이렇게 서비스에에 업로드 한 파일을 저장합니다

public void Upload(Stream stream) 
{ 
    string filepath = "some path with filename and extension"; // corrected filepath mistyping 

    MultipartParser parser = new MultipartParser(stream); 
    if (parser.Success) 
    { 
     // Save the file 
     File.WriteAllBytes(filepath, parser.FileContents) 
    } 
} 
관련 문제