We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you two Citrix podcasts. Learn about 2020 trends and get answers to your biggest Citrix questions!Listen Now

x

Flash 8 FileReference Upload on SSL???

spiroosx
spiroosx asked
on
Medium Priority
707 Views
Last Modified: 2010-05-19
Hi All,

I am frantically trying to get this the new FileReference function in Flash 8 to work under ssl.
It says it can support ssl but the files are never uploaded. Http OK / HTTPS not OK.

A demo of it running can be found here: http://www.tink.ws/blog/files/flash8/UploadExample.html (not my site)

and the source here: http://www.tink.ws/blog/files/flash8/FileReference.zip

What do i need to alter to make it work. I have changed all the tags to https but no change all that happens is the status bar sits at zero % and the text just continually says "upload started".

Any advice would be greatly appreciated.

Many thanks in advance

spiroosx
 
Comment
Watch Question

Hi,

I spent hours (no, days!) trying to work this out. I develop online web applictions and needed to use FileReference over SSL.

If you have got everything else sorted, all you need to do is to specify ':443' after the domain name to are uploading/downloading from. And of course make sure you have 'https'! So for example:

blahblah.upload('https://www.yourdomain.com:443/files/stuff/whatever')

Flash defaults to using port 80, which is for http. Even if you specify https at the beginning of the URL.

I really hope this works for you. I know how frustrating this can be!!

Miles

Author

Commented:
Hi Miles,

Thank you for coming back to me :-)

I have tried your solution and unfortunatley i am a little uncear as to where the port is specified.

The setup i have is all the contents of http://www.tink.ws/blog/files/flash8/FileReference.zip
uploaded into a folder called "upload"

so the path to this folder is:

https://www.mysite.co.uk/upload/UploadExample.html

I have changed the tags in the html page to be https.

Obviously if i enter https://www.mysite.co.uk:443/upload/UploadExample.html nothing happens so i then have gone through the imported .as file shown below:

Would i change: success = this._fileRef.upload(UploadExample.URL);

to: success = this._fileRef.upload(https://www.mysite.co.uk:443/upload/); ???

Any further help would be greatly appreciated.

Many thanks

spiroosx




/////////////////////////////////////////////
//Imports
/////////////////////////////////////////////
import mx.utils.Delegate;

import mx.controls.TextArea;
import mx.controls.ProgressBar;
import mx.controls.Button;

import flash.net.FileReference;
/////////////////////////////////////////////
      /////////////////////////////////////////////



class UploadExample extends MovieClip
{
      
      
      
      /////////////////////////////////////////////
      //Components
      /////////////////////////////////////////////
      //TextArea component
      private var _textArea:TextArea;
      //ProgressBar component
      private var _progressBar:ProgressBar;
      //Button components
      private var _browse_btn:Button;
      private var _upload_btn:Button;
      /////////////////////////////////////////////
      /////////////////////////////////////////////
      
      /////////////////////////////////////////////
      //FileReference object
      /////////////////////////////////////////////
      private var _fileRef:FileReference;
      /////////////////////////////////////////////
      /////////////////////////////////////////////
      
      /////////////////////////////////////////////
      //server script configured to handle upload through HTTP POST calls
      /////////////////////////////////////////////
      private static var URL:String = "upload.php";
      /////////////////////////////////////////////
      /////////////////////////////////////////////
      
      
      
      /////////////////////////////////////////////
      //Constructor
      /////////////////////////////////////////////
      public function UploadExample()
      {
            super();
      }
      /////////////////////////////////////////////
      /////////////////////////////////////////////
      
      
      
      /////////////////////////////////////////////
      //onLoad
      /////////////////////////////////////////////
      private function onLoad():Void
      {
            this._textArea.fontSize = 15;

            this._progressBar.mode = "manual";
            
            this._browse_btn.label = "Browse";
            this._browse_btn.onPress = Delegate.create(this, this.browse);
            
            this._upload_btn.label = "Upload";
            this._upload_btn.onPress = Delegate.create(this, this.upload);
            
            this._fileRef = new FileReference();
            this._fileRef.addListener(this);
      }
      /////////////////////////////////////////////
      /////////////////////////////////////////////


      
      /////////////////////////////////////////////
      //Button events
      /////////////////////////////////////////////
      private function browse():Void
      {
            var success:Boolean;
            
            //open OS window and specify a description for each group and the file types allowed in that group
            success = this._fileRef.browse([{description: "All Formats (*.jpg,*.gif,*.png,*.swf)", extension: "*.jpg;*.gif;*.png;*.swf", macType: "JPEG;jp2_;GIFF;SWFL"},
                                                            {description: "All Image Formats (*.jpg,*.gif,*.png)", extension: "*.jpg;*.gif;*.png", macType: "JPEG;jp2_;GIFF"},
                                                            {description: "Flash Movies (*.swf)", extension: "*.swf", macType: "SWFL"}]);
            
            //if the OS window failed to open
            if(success == false)
            {
                  this._textArea.text += "OS window failed to open\n////////////////////////////////////////////////////////////////////////////\n\n";
                  
                  this._textArea.vPosition = this._textArea.maxVPosition;
            }
      }
      
      
      
      private function upload():Void
      {
            var success:Boolean;
            
            //start upload process
            success = this._fileRef.upload(UploadExample.URL);
            
            //if the upload process failed to start
            if(success == false)
            {
                  this._textArea.text += "upload process failed to start\n////////////////////////////////////////////////////////////////////////////\n\n";
                  
                  this._textArea.vPosition = this._textArea.maxVPosition;
            }
      }
      /////////////////////////////////////////////
      /////////////////////////////////////////////
            
            
      
      /////////////////////////////////////////////
      //FileReference events
      /////////////////////////////////////////////
      private function onSelect(fileRef:FileReference):Void
      {      
            this._textArea.text += "file selected to upload\n\n";
            
            this._textArea.text += "file details\n";
            this._textArea.text += "name: " + fileRef.name + "\n";
            this._textArea.text += "type: " + fileRef.type + "\n";
            this._textArea.text += "size: " + fileRef.size + "\n";
            this._textArea.text += "creator: " + fileRef.creator + "\n";
            this._textArea.text += "created: " + fileRef.creationDate + "\n";
            this._textArea.text += "last modified: " + fileRef.modificationDate + "\n////////////////////////////////////////////////////////////////////////////\n\n";
            
            this._textArea.vPosition = this._textArea.maxVPosition;
      }
      
      
      
      private function onOpen(fileRef:FileReference):Void
      {
            this._textArea.text += "upload started\n////////////////////////////////////////////////////////////////////////////\n\n";
            
            this._textArea.vPosition = this._textArea.maxVPosition;
      }
      
      
      
      private function onProgress(fileRef:FileReference, loaded_num:Number, total_num:Number):Void
      {
            this._progressBar.setProgress(loaded_num, total_num);
      }
      
      
      
      private function onComplete(fileRef:FileReference):Void
      {
            this._progressBar.setProgress(100, 100);
            
            this._textArea.text += "upload successful\n////////////////////////////////////////////////////////////////////////////\n\n";
            
            this._textArea.vPosition = this._textArea.maxVPosition;
      }
      
      
      
      private function onCancel():Void
      {
            this._textArea.text += "OS window dismissed\n////////////////////////////////////////////////////////////////////////////\n\n";
      }
      
      
      
      private function onHTTPError(fileRef:FileReference):Void
      {
            this._textArea.text += "onHTTPError: " + fileRef.name + "\n////////////////////////////////////////////////////////////////////////////\n\n";
                  
            this._textArea.vPosition = this._textArea.maxVPosition;
      }
      
      
      
      private function onIOError(fileRef:FileReference):Void
      {
            this._textArea.text += "onIOError: " + fileRef.name + "\n////////////////////////////////////////////////////////////////////////////\n\n";
            
            this._textArea.vPosition = this._textArea.maxVPosition;
      }
      
      
      
      private function onSecurityError(fileRef:FileReference, error_str:String):Void
      {
            this._textArea.text += "onSecurityError: " + fileRef.name + "   error : " + error_str + "\n////////////////////////////////////////////////////////////////////////////\n\n";
            
            this._textArea.vPosition = this._textArea.maxVPosition;
      }
      /////////////////////////////////////////////
      /////////////////////////////////////////////



}
Hello there,

Yes you need to explicitly specify the absolute path to the upload php script (upload.php).

So changing:  success = this._fileRef.upload(UploadExample.URL);

to: success = this._fileRef.upload(https://www.mysite.co.uk:443/upload/upload.php);  

Should do the trick. In fact, it will probably be easier if you change your variable definition at the start of your class:    

from;     private static var URL:String = "upload.php";
to;         private static var URL:String = "https://www.mysite.co.uk:443/upload/upload.php";

Let me know if this works? I hope you get a result ;)

Regards

Miles



Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts

Author

Commented:
Hi Miles.

Thank you very much - you have made my week :-)

That works great

Cheers

spiroosx
Hello Spiroosx,

I am very pleased to be of assistance! Good luck with the project...

Miles
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.