Select to view content in your preferred language

uploading to server through flex

527
0
04-05-2012 08:17 AM
MattGiles
Deactivated User
I am writing a flex app that lets users upload a file to our server remotely. I use the fileReference.upload command to send the file to a server side script (.aspx) that will save it in an 'uploads' folder in the wwwroot on the server. I am having problems getting the server side script to work..

I have NO experience with .NET programming and found this script online:
dim myFile as HttpPostedFile=Request.Files(0)
myFile.SaveAs(Server.MapPath("~") & "uploads/" & myFile.FileName)


Can someone explain why this wont work with fileReference.upload()?


Alternatively, I found this script (which includes a form):
<%@ Import namespace="System.IO"%> 
<html> 
<head> 
<title>Uploading a File</title>  
<script language="VB" runat="server">

Sub Upload_Click(source As Object, e As EventArgs)
If Not (uploadedFile.PostedFile Is Nothing) Then
Try
Dim postedFile = uploadedFile.PostedFile
Dim filename As String = Path.GetFileName(postedFile.FileName)
Dim contentType As String = postedFile.ContentType
Dim contentLength As Integer = postedFile.ContentLength

postedFile.SaveAs(Server.MapPath("~") & "uploads/" & filename)

message.Text = postedFile.Filename & " uploaded" & _
"<br>content type: " & contentType & _
"<br>content length: " & contentLength.ToString()
Catch exc As Exception
message.Text = "Failed uploading file"
End Try
End If
End Sub
</script>

</head>
//<body>
//<form enctype="multipart/form-data" runat="server"> 
//Select ZIPPED Shapefile to Upload:  
//<input id="uploadedFile" type="file" runat="server"> 
//<p> 
//<input type=button id="upload"  
//value="Upload"
//OnServerClick="Upload_Click"
//runat="server">
//<p> 
//<asp:Label id="message" runat="server"/> 
//</form> 
//</body>
</html>


This successfully uploads the file to the server, but then i run into the problem of somehow telling my flex app that the file was uploaded successfully so I can continue with the flex code...


Any suggestions?
Thanks!
Tags (2)
0 Kudos
0 Replies