<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" layout="absolute">
public var fileRef:FileReference;
public function startUpload():void
fileRef = new FileReference();
var suc:Boolean = fileRef.browse();
trace("Unable to browse for files.");
public function selectHandler(event:Event):void
var request:URLRequest = new URLRequest(" http://www....");
trace("Unable to upload file.");
public function completeHandler(event:Event):void
<mx:Button label="Upload" click="startUpload();" />
Thanks for the reply.
But the thing is , if we're doing it this way in Flex , I dont know how to accept the upload in ASP.NET.
Like I said above , the sample I saw on ASP.NET is that it's using a HtmlInputFile, which is an aspx component, and it can only be used for upload from aspx page, while I need to upload from Flex.
This is one sample of using HtmlInputFile in ASP.NET :
Ah ok found it.
Turns out to be quite simple.
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim file As HttpPostedFile = Request.Files(0)
I have my flex uploading in asp.net but I'm trying to change the file name when it uploads....
How are you accessing your Sub from flex? with a POST??
I'm using FileReference object, which means it use POST to upload.
I dont see how you can change the name of the file being browse.
Although you might can save it as a different name on the server.
Yea thats what I'm trying to do....But I can't seem to send the new file name to the the POST or the server script. Do you have any Idea how to accomplish this?
You could use query string on the url :
On the Flex code :
var url:String = " http://www.server.com/upload.aspx?filename=xxx.txt";
And on the ASP.NET code :
Dim filename As String = Request.Params("filename")
Thanks that worked perfectly
I am trying to accomplish the same thing without success so far.
I have a FileReference.upload in my app and now I don't know how the ASP script should look like. I tried your example but, to begin with, MyBase.Load is not accepted.
Then I don't know how does your code accept a parameter. Do you have a Web Service as in my case? I wrote this but I don't know if it's right:
Public Function importFile(ByVal f As Byte(), ByVal fileName As String) As String
Dim ms As New MemoryStream(f)
Dim fs As New FileStream(System.Web.Hosting.HostingEnvironment.MapPath("C:\temp") & fileName, FileMode.Create)
Catch ex As Exception
Thanks in advance,