mfrias
07-27-2010, 11:44 AM
Hi,
I am building a web service in ASP.NET to allow users to upload a .csv file into SQL Server via a Flex interface.
So far I have the following function in Flex that fires up when the user selects a file:
private function uploadFile(event:MouseEvent):void
{
if (!fileSelected)
Alert.show("Select a file!");
else
fileRef.upload(new URLRequest("webserviceFunctionAddress"));
}
And in ASP.NET I have this Web function that for the moment stores the file in the server:
<WebMethod()> _
Public Function importFile(ByVal f As Byte(), ByVal fileName As String) As String
Try
Dim ms As New MemoryStream(f)
Dim fs As New FileStream(System.Web.Hosting.HostingEnvironment.M apPath("C:temp") & fileName, FileMode.Create)
ms.WriteTo(fs)
ms.Close()
fs.Close()
fs.Dispose()
Return "ok"
Catch ex As Exception
Return ex.Message.ToString()
End Try
End Function
When I execute the Flex app I always get the error 2038 and httpFox says that no request is made to the server.
The web service function is asking for two values but even if I delete the filename as a parameter the error persists.
There must be something wrong or maybe I have a totally wrong approach. Any ideas, links or suggestions are appreciated.
Manolo
I am building a web service in ASP.NET to allow users to upload a .csv file into SQL Server via a Flex interface.
So far I have the following function in Flex that fires up when the user selects a file:
private function uploadFile(event:MouseEvent):void
{
if (!fileSelected)
Alert.show("Select a file!");
else
fileRef.upload(new URLRequest("webserviceFunctionAddress"));
}
And in ASP.NET I have this Web function that for the moment stores the file in the server:
<WebMethod()> _
Public Function importFile(ByVal f As Byte(), ByVal fileName As String) As String
Try
Dim ms As New MemoryStream(f)
Dim fs As New FileStream(System.Web.Hosting.HostingEnvironment.M apPath("C:temp") & fileName, FileMode.Create)
ms.WriteTo(fs)
ms.Close()
fs.Close()
fs.Dispose()
Return "ok"
Catch ex As Exception
Return ex.Message.ToString()
End Try
End Function
When I execute the Flex app I always get the error 2038 and httpFox says that no request is made to the server.
The web service function is asking for two values but even if I delete the filename as a parameter the error persists.
There must be something wrong or maybe I have a totally wrong approach. Any ideas, links or suggestions are appreciated.
Manolo