I know I'm probably just doing something wrong - I'm a Noob w/ flex.

I'm using FileReference.upload to upload a file to a server and it's
uploading the file OK, but some of the 'options' are not working for
me. For example I'm trying to use the uploadDataFieldName parameter to
change the fieldname that is being uploaded. (I know I can just change 
it on the server, and I probably will, but it just bugs me) 

from the docs:
public function upload(request:URLRequest, uploadDataFieldName:String
= "Filedata", testUpload:Boolean = false):void

so the second parameter should be used to change that name. 

The other problem is probably bigger for me, I am trying to send some
other values along with the post. I set up my URLVariables and assign
values in there and set request.data = variables, just like is shown
in the docs, but these don't come through.

Here is a section of the code (along with a few things I'm doing to
convince myself that I didn't have a cached swf or something):

            var request:URLRequest = new URLRequest();
            var uploadname:String = new String();
            request.url = UPLOAD_URL;
            var variables:URLVariables = new URLVariables();    
            variables.description = "Hello from flash";
            
            request.data = variables;
            request.method = URLRequestMethod.POST
            import mx.controls.Alert;
            uploadname = "attached_file"
            Alert.show(uploadname);   
            fr.upload(request,uploadname);

and here is my post data:

------------------------------5a2537304aa5
Content-Disposition: form-data; name="Filename"

testfile.txt
------------------------------5a2537304aa5
Content-Disposition: form-data; name="Filedata"; filename="testfile.txt"
Content-Type: application/octet-stream

*** begin file ***

This is my file

*** end file ***
------------------------------5a2537304aa5
Content-Disposition: form-data; name="Upload"

Submit Query
------------------------------5a2537304aa5--

I haven't got the slightest idea where the 'Upload' is coming from
fr is the FileReference and most of the rest of the code is straight
out of an example from Programming in ActionScript 3.0 that I found
somewhere.

Any pointers??

Thanks in advance,

Kelly


Reply via email to