1

PhoneGap アプリケーションからサーバー上のフォルダーに画像をアップロードしようとしています。次の方法で、サーバー側に安らかなWSがあります。

[OperationContract]
[WebInvoke(Method = "POST", ResponseFormat = WebMessageFormat.Json,  UriTemplate = "fileUpload")]
    string fileUpload(Stream fileStream); 


public string fileUpload(Stream fileStream)
         {
         try
             {
             FileStream fileToupload = new FileStream("D:\\FileUpload\\" + "images.jpg", FileMode.Create);

             byte[] bytearray = new byte[10000];
             int bytesRead, totalBytesRead = 0;
             do
                 {
                 bytesRead = fileStream.Read(bytearray, 0, bytearray.Length);
                 totalBytesRead += bytesRead;
                 } while (bytesRead > 0);

             fileToupload.Write(bytearray, 0, bytearray.Length);
             fileToupload.Close();
             fileToupload.Dispose();

             return "Success;

             }
         catch (Exception e)
             {
             return e.Message;
             throw (e);
             }                   
         }

http://docs.phonegap.com/en/2.3.0/cordova_file_file.md.html#FileUploadOptionsの最も一般的な例を使用する と、適切な場所に画像がアップロードされ、成功の電話がかかってきますが、画像を開くことができませんその後、「windows viewer」に「破損、破損、または大きすぎます」と表示されます。メモ帳++で画像を開くと、物乞いの画像に次のテキストがあります。

--*****
Content-Disposition: form-data; name="value1";

test
--*****
Content-Disposition: form-data; name="value2";

param
--*****
Content-Disposition: form-data; name="file"; filename="32"
Content-Type: image/jpeg

これらの部分を削除すると、元の正しいイメージが得られます。サーバー側でこれらのデータを処理する方法。画像の名前とパラメーターを取り出して文字列として使用し、これらのパラメーターを使用せずに画像コンテンツのみを画像にプッシュしたいですか?

ありがとう、ミロス

4

0 に答える 0