4 Replies Latest reply on Aug 16, 2007 11:52 AM by ntsiii

    Upload File through flex using a .net Web Service

    rsegecin
      Hi I've a web service that requires three values nickname as string, password as string and imageData as byte. I was wondering if I could use this web service to upload file from my flex application and how should I do it.

      Thank you very much.
        • 1. Re: Upload File through flex using a .net Web Service
          mitchgrrt Level 1
          Did you ever find an answer? I am looking at a similar problem today. Thanks.
          • 2. Re: Upload File through flex using a .net Web Service
            ntsiii Level 3
            You can upload files from Flex using the FileReference class, but not with WebService.

            On the .net side, i use this function (sorry that the forum destroys formatting):
            Public Shared Function saveUploadFile(ByVal context As HttpContext, _
            Optional ByRef sErrInfo As String = "") As Boolean


            Dim bReturn As Boolean = False
            Dim postedFile As HttpPostedFile = context.Request.Files(0)
            Dim sDestFolderRoot As String = ConfigurationSettings.AppSettings.Get("sUploadRootFolder")
            Dim sCustomerFolder As String = Utility.nullHandler(context.Request("customerFolder"))
            'sCustomerFolder = sCustomerFolder.Replace("/", "\")
            Dim sFileName As String = postedFile.FileName
            Dim sFileSpec As String = sDestFolderRoot & sCustomerFolder & System.IO.Path.GetFileName(sFileName)
            If Not postedFile Is Nothing And sFileName <> "" Then
            postedFile.SaveAs(sFileSpec)
            bReturn = True
            LogEvent.logEventEntry("edd_p_suf", "EchoDomeData", "Persistence", "info", "Saving uploaded file to: " & sFileSpec)
            Else
            bReturn = False
            sErrInfo &= "No files sent."
            End If
            Return bReturn
            End Function
            • 3. Re: Upload File through flex using a .net Web Service
              mitchgrrt Level 1
              So does this mean you POST the file to a servlet, rather than to a web service? That is what we were afraid we would have to do too.

              "Servlet" may not be the right word in the .net world. Maybe "executable program on the server with a URL address" is the terminology.

              Anyway thanks a lot for the help.
              • 4. Re: Upload File through flex using a .net Web Service
                ntsiii Level 3
                Yes, I use an aspx file with no UI. Set:
                <%Response.ContentType = "text/xml"%> in the aspx page, and always return xml strings in the response.

                Tracy