locked
(metro)How to upload a file to a web server by BackgroundUploader?

    Question

  • I want to use BackgroundUploader to uploader an image to a web server,

    when I us the code below

    ----code-----

     multipart/form-data or multipart/mixed stream, content type header is null

       BackgroundUploader^ uploader = ref new BackgroundUploader();
         uploader->Method = "POST";
        uploader->SetRequestHeader("Content-Type","multipart/form-data);

    ----code-----

    The web server error log:

    (org.apache.commons.fileupload.FileUploadBase$InvalidContentTypeException: the request doesn't contain a multipart/form-data or multipart/mixed stream, content type header is null )

    so I modify the code:

    ----code-----

    multipart/form-data or multipart/mixed stream, content type header is null

       BackgroundUploader^ uploader = ref new BackgroundUploader();
         uploader->Method = "POST";
        uploader->SetRequestHeader("Content-Type","multipart/form-data;boundary=45309FFF-   BD65-4d50-99C9-36986896A96F"); 

    ----code-----

    but the web server error log show:

    (org.apache.commons.fileupload.FileUploadException: the request was rejected because no multipart boundary was found)

    Does any one uploade the file to a web server success?? please give me some opinion thanks!

    Monday, June 25, 2012 8:51 AM

All replies