0 Replies Latest reply on Aug 27, 2011 12:08 PM by aligned2009

    How to get FileReference Parameters to Mimic Form Post

    aligned2009 Level 1

      Caveat : I added a bunch of RichText to this, but it doesn't seem to save!

       

      Parameters: { ########These parameters are from a standard form POST

      "utf8"=>"✓",

      "authenticity_token"=>"IvUPARKQNAqfC5Evd0ZU4vqKhxybdQVN5v5WQEH3QK8=",

      "image"=>{"image"=>#<ActionDispatch::Http::UploadedFile:0x007fac570b7628

           @original_filename="Strawberry.gif",

           @content_type="image/gif",

           @headers="Content-Disposition: form-data; name=\"image[image]\";filename=\"Strawberry.gif\"\r\nContent-Type: image/gif\r\n",

           @tempfile=#<File:/var/folders/y1/8mr7fwrj6t90nschd5l16lvc0000gn/T/Rac kMultipart20110827-15379-1gfsy4e>>}, "commit"=>"Save Image"}

       

       

      Parameters: { ##########These parameters are from a FileReference.upload POST

      "Filename"=>"Sunflower.gif",

      "Filedata"=>#<ActionDispatch::Http::UploadedFile:0x007fac55643f80

      @original_filename="Sunflower.gif",

      @content_type="application/octet-stream",

      @headers="Content-Disposition: form-data; name=\"Filedata\"; filename=\"Sunflower.gif\"\r\nContent-Type: application/octet-stream\r\n",

      @tempfile=#<File:/var/folders/y1/8mr7fwrj6t90nschd5l16lvc0000gn/T/RackMultipart 20110827-15379-t2hjl4>>, "Upload"=>"Submit Query"}

       

      The code handler for Event.SELECT from FileReference object:

       

      private function fileSelectedByUserHandler(event:Event):void{

           var file:FileReference = FileReference(event.target);

           var r:URLRequest=new URLRequest("http://localhost/images");

           file.upload(r);

      }

       

      Question

       

      I would like the FileReference.upload POST to have the variables in RED as values of the hash key 'images' as in the form POST. The FileReference.upload POST should look like the following:

       

       

      Parameters: { These are parameters I'd like to see from the above FileReference.upload POST

      "Filename"=>"Sunflower.gif",

      "image"=>{"Filedata"=>#<ActionDispatch::Http::UploadedFile:0x007fac55643f80

           @original_filename="Sunflower.gif",

           @content_type="application/octet-stream",

           @headers="Content-Disposition: form-data; name=\"Filedata\"; filename=\"Sunflower.gif\"\r\nContent-Type:                application/octet-stream\r\n",

           @tempfile=#<File:/var/folders/y1/8mr7fwrj6t90nschd5l16lvc0000gn/T/RackMultipart20110827-1 5379-t2hjl4>>, "Upload"=>"Submit Query"}}

       

       

       

      How do I modify the FileReference object so that the image key is added to the post structure, and the currently existing variables are moved underneath the image key?

       

       

      Thanks...