3 Replies Latest reply on Feb 5, 2008 2:30 PM by Arty13

    FileReference with authentication

    ejthsiao
      I am trying to do a file upload using FileReference to a secure server. However, it seems FileReference does not support authentication at this point. Does any one know if there's a work around for this? Thanks!

      Eric
        • 1. Re: FileReference with authentication
          Arty13 Level 1
          You could always post your authentication in the requestURL as headers when you do fileReference.uplode(). Look under the URLRequest.requestHeaders property for more info, also look at URLRequestHeader specifically in the help docs.

          Hope that helps you some.

          Art
          • 2. Re: FileReference with authentication
            ejthsiao Level 1
            Hi, Art,

            Thanks for the information.. I tried it but it did not work..

            uploadRequest = new URLRequest(urlInput.text);
            uploadRequest.method = URLRequestMethod.POST;

            var variables:URLVariables = new URLVariables();
            variables.Authorization = "Basic username:password";
            uploadRequest.data = variables;

            In the mean time,
            I dug out an article which said

            "The FileReference.upload() and FileReference.download() methods do not support the URLRequest.requestHeaders parameter."

            Also in Adobe document, it said
            "The FileReference and FileReferenceList classes also do not provide methods for authentication. With servers that require authentication, you can download files with the Flash® Player browser plug-in, but uploading (on all players) and downloading (on the stand-alone or external player) fails. Listen for FileReference events to determine whether operations complete successfully and to handle errors."

            Does this sound right?


            Eric
            • 3. Re: FileReference with authentication
              Arty13 Level 1
              The RequestHeaders and the URLVariables are different from each other.

              The URLVariables are posted variables to the server. So if you are running a PHP server, you should be getting a variable in the $_POST named "Authorization" with a value of "Basic username:password"

              so on the PHP script, you will have $_POST["Authorization"] and you can do whatever you want with the value of that.

              just to double check, when you do your
              myFileReference.upload(uploadRequest);
              request, is it successfully getting to your server?


              But as for the RequestHeaders, the information you have found may be accurate.

              Hope I'm some help to ya.

              Art