[Flashcoders] AS3 - Upload image problem

2008-05-20 Thread SJM - Flash
Hi guys im having problems with uploading an image, i cant seam to get it to 
work! Most of the code is from the help files but still no joy! Any ideas...

public function uploadImage( ev:MouseEvent ):void
  {
   uploadURL = new URLRequest();
uploadURL.url = _mainClass._imgUploadURL;
file = new FileReference();
file.browse(getTypes());   
trace(uploadImage:  + ev);
  }


The above trace outouts this...

uploadImage: [MouseEvent type=click bubbles=true cancelable=false 
eventPhase=3 localX=16 localY=4 stageX=95.65 stageY=236.72 
relatedObject=null ctrlKey=false altKey=false shiftKey=false delta=0]]

As far as i can tell it does not go any further into the code below!

private function getTypes():Array {
var allTypes:Array = new Array(getImageTypeFilter());
return allTypes;
}


private function getImageTypeFilter():FileFilter {
return new FileFilter(Images (*.jpg, *.jpeg), *.jpg;*.jpeg;);
}


private function cancelHandler(ev:Event):void {
trace(cancelHandler:  + ev);
}

private function completeHandler(ev:Event):void {
trace(completeHandler:  + ev);
}

private function uploadCompleteDataHandler(ev:Event):void {
trace(uploadCompleteData:  + ev);
_xmlClass.xmlLoader(bannerInfo.xml);
_xmlClass.addEventListener(Event.COMPLETE, 
_mainClass.afterUploadXML);
}

private function httpStatusHandler(ev:HTTPStatusEvent):void {
trace(httpStatusHandler:  + ev);
}

private function ioErrorHandler(ev:IOErrorEvent):void {
trace(ioErrorHandler:  + ev);
}

private function openHandler(ev:Event):void {
trace(openHandler:  + ev);
}

private function progressHandler(ev:ProgressEvent):void {
var file:FileReference = FileReference(ev.target);
trace(progressHandler name= + file.name +  bytesLoaded= + 
ev.bytesLoaded +  bytesTotal= + ev.bytesTotal);
}

private function selectHandler(event:Event):void {
var file:FileReference = FileReference(event.target);
trace(selectHandler: name= + file.name +  URL= + uploadURL.url);
file.upload(uploadURL);
}
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] AS3 - Upload image problem

2008-05-20 Thread Glen Pike

http://www.tink.ws/blog/a-round-trip-with-filereference/

SJM - Flash wrote:

Hi guys im having problems with uploading an image, i cant seam to get it to 
work! Most of the code is from the help files but still no joy! Any ideas...

public function uploadImage( ev:MouseEvent ):void
  {
   uploadURL = new URLRequest();
uploadURL.url = _mainClass._imgUploadURL;
file = new FileReference();
file.browse(getTypes());   
trace(uploadImage:  + ev);

  }


The above trace outouts this...

uploadImage: [MouseEvent type=click bubbles=true cancelable=false 
eventPhase=3 localX=16 localY=4 stageX=95.65 stageY=236.72 relatedObject=null 
ctrlKey=false altKey=false shiftKey=false delta=0]]

As far as i can tell it does not go any further into the code below!

private function getTypes():Array {
var allTypes:Array = new Array(getImageTypeFilter());
return allTypes;
}


private function getImageTypeFilter():FileFilter {
return new FileFilter(Images (*.jpg, *.jpeg), *.jpg;*.jpeg;);
}


private function cancelHandler(ev:Event):void {
trace(cancelHandler:  + ev);
}

private function completeHandler(ev:Event):void {
trace(completeHandler:  + ev);
}

private function uploadCompleteDataHandler(ev:Event):void {
trace(uploadCompleteData:  + ev);
_xmlClass.xmlLoader(bannerInfo.xml);
_xmlClass.addEventListener(Event.COMPLETE, 
_mainClass.afterUploadXML);
}

private function httpStatusHandler(ev:HTTPStatusEvent):void {
trace(httpStatusHandler:  + ev);
}

private function ioErrorHandler(ev:IOErrorEvent):void {

trace(ioErrorHandler:  + ev);
}

private function openHandler(ev:Event):void {
trace(openHandler:  + ev);
}

private function progressHandler(ev:ProgressEvent):void {
var file:FileReference = FileReference(ev.target);
trace(progressHandler name= + file.name +  bytesLoaded= + ev.bytesLoaded 
+  bytesTotal= + ev.bytesTotal);
}

private function selectHandler(event:Event):void {
var file:FileReference = FileReference(event.target);
trace(selectHandler: name= + file.name +  URL= + uploadURL.url);
file.upload(uploadURL);
}  
___

Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


  


--

Glen Pike
01326 218440
www.glenpike.co.uk http://www.glenpike.co.uk

___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] AS3 - Upload image problem

2008-05-20 Thread SJM - Flash
Glen is that not for AS2?
  - Original Message - 
  From: Glen Pike 
  To: Flash Coders List 
  Sent: Tuesday, May 20, 2008 12:30 PM
  Subject: Re: [Flashcoders] AS3 - Upload image problem


  http://www.tink.ws/blog/a-round-trip-with-filereference/

  SJM - Flash wrote:
   Hi guys im having problems with uploading an image, i cant seam to get it 
to work! Most of the code is from the help files but still no joy! Any ideas...
  
   public function uploadImage( ev:MouseEvent ):void
 {
  uploadURL = new URLRequest();
   uploadURL.url = _mainClass._imgUploadURL;
   file = new FileReference();
   file.browse(getTypes());   
   trace(uploadImage:  + ev);
 }
  
  
   The above trace outouts this...
  
   uploadImage: [MouseEvent type=click bubbles=true cancelable=false 
eventPhase=3 localX=16 localY=4 stageX=95.65 stageY=236.72 
relatedObject=null ctrlKey=false altKey=false shiftKey=false delta=0]]
  
   As far as i can tell it does not go any further into the code below!
  
   private function getTypes():Array {
   var allTypes:Array = new Array(getImageTypeFilter());
   return allTypes;
   }
  
  
   private function getImageTypeFilter():FileFilter {
   return new FileFilter(Images (*.jpg, *.jpeg), 
*.jpg;*.jpeg;);
   }
  
  
   private function cancelHandler(ev:Event):void {
   trace(cancelHandler:  + ev);
   }
  
   private function completeHandler(ev:Event):void {
   trace(completeHandler:  + ev);
   }
  
   private function uploadCompleteDataHandler(ev:Event):void {
   trace(uploadCompleteData:  + ev);
   _xmlClass.xmlLoader(bannerInfo.xml);
   _xmlClass.addEventListener(Event.COMPLETE, 
_mainClass.afterUploadXML);
   }
  
   private function httpStatusHandler(ev:HTTPStatusEvent):void {
   trace(httpStatusHandler:  + ev);
   }
   
   private function ioErrorHandler(ev:IOErrorEvent):void {
   trace(ioErrorHandler:  + ev);
   }
  
   private function openHandler(ev:Event):void {
   trace(openHandler:  + ev);
   }
  
   private function progressHandler(ev:ProgressEvent):void {
   var file:FileReference = FileReference(ev.target);
   trace(progressHandler name= + file.name +  bytesLoaded= + 
ev.bytesLoaded +  bytesTotal= + ev.bytesTotal);
   }
  
   private function selectHandler(event:Event):void {
   var file:FileReference = FileReference(event.target);
   trace(selectHandler: name= + file.name +  URL= + 
uploadURL.url);
   file.upload(uploadURL);
   }  
   ___
   Flashcoders mailing list
   Flashcoders@chattyfig.figleaf.com
   http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
  
  
 

  -- 

  Glen Pike
  01326 218440
  www.glenpike.co.uk http://www.glenpike.co.uk

  ___
  Flashcoders mailing list
  Flashcoders@chattyfig.figleaf.com
  http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] AS3 - Upload image problem

2008-05-20 Thread Glen Pike

Apologies, it is.

You need to add listeners for all the events that FileReference dispatches.

At a minimum you need to listen for the select event to begin uploading:


file.addEventListener(Event.SELECT, selectHandler);


Here is  a link to the Flex 2 langref with an example that adds all the 
listeners - check the Flash one if you are using CS3, but the class 
should be the same, so you may be okay.


http://livedocs.adobe.com/flex/201/langref/flash/net/FileReference.html#includeExamplesSummary

HTH

Glen



SJM - Flash wrote:

Glen is that not for AS2?
  - Original Message - 
  From: Glen Pike 
  To: Flash Coders List 
  Sent: Tuesday, May 20, 2008 12:30 PM

  Subject: Re: [Flashcoders] AS3 - Upload image problem


  http://www.tink.ws/blog/a-round-trip-with-filereference/

  SJM - Flash wrote:
   Hi guys im having problems with uploading an image, i cant seam to get it 
to work! Most of the code is from the help files but still no joy! Any ideas...
  
   public function uploadImage( ev:MouseEvent ):void
 {
  uploadURL = new URLRequest();
   uploadURL.url = _mainClass._imgUploadURL;
   file = new FileReference();
   file.browse(getTypes());   
   trace(uploadImage:  + ev);

 }
  
  
   The above trace outouts this...
  
   uploadImage: [MouseEvent type=click bubbles=true cancelable=false 
eventPhase=3 localX=16 localY=4 stageX=95.65 stageY=236.72 relatedObject=null 
ctrlKey=false altKey=false shiftKey=false delta=0]]
  
   As far as i can tell it does not go any further into the code below!
  
   private function getTypes():Array {
   var allTypes:Array = new Array(getImageTypeFilter());
   return allTypes;
   }
  
  
   private function getImageTypeFilter():FileFilter {
   return new FileFilter(Images (*.jpg, *.jpeg), 
*.jpg;*.jpeg;);
   }
  
  
   private function cancelHandler(ev:Event):void {
   trace(cancelHandler:  + ev);
   }
  
   private function completeHandler(ev:Event):void {
   trace(completeHandler:  + ev);
   }
  
   private function uploadCompleteDataHandler(ev:Event):void {
   trace(uploadCompleteData:  + ev);
   _xmlClass.xmlLoader(bannerInfo.xml);
   _xmlClass.addEventListener(Event.COMPLETE, 
_mainClass.afterUploadXML);
   }
  
   private function httpStatusHandler(ev:HTTPStatusEvent):void {
   trace(httpStatusHandler:  + ev);
   }
   
   private function ioErrorHandler(ev:IOErrorEvent):void {

   trace(ioErrorHandler:  + ev);
   }
  
   private function openHandler(ev:Event):void {
   trace(openHandler:  + ev);
   }
  
   private function progressHandler(ev:ProgressEvent):void {
   var file:FileReference = FileReference(ev.target);
   trace(progressHandler name= + file.name +  bytesLoaded= + 
ev.bytesLoaded +  bytesTotal= + ev.bytesTotal);
   }
  
   private function selectHandler(event:Event):void {
   var file:FileReference = FileReference(event.target);
   trace(selectHandler: name= + file.name +  URL= + 
uploadURL.url);
   file.upload(uploadURL);
   }  
   ___

   Flashcoders mailing list
   Flashcoders@chattyfig.figleaf.com
   http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
  
  
 

  -- 


  Glen Pike
  01326 218440
  www.glenpike.co.uk http://www.glenpike.co.uk

  ___
  Flashcoders mailing list
  Flashcoders@chattyfig.figleaf.com
  http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


  


--

Glen Pike
01326 218440
www.glenpike.co.uk http://www.glenpike.co.uk

___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] AS3 - Upload image problem

2008-05-20 Thread Jimbo
Here's one if you don't want to roll your own- it's really easy to customize:
http://www.flepstudio.org/english/utilities/free-utilities/flash-cs3-uploader-_-free-utility-2007073189.html

jimbo

*** REPLY SEPARATOR  ***

On 5/20/2008 at 12:44 PM SJM - Flash wrote:

Glen is that not for AS2?
  - Original Message - 
  From: Glen Pike 
  To: Flash Coders List 
  Sent: Tuesday, May 20, 2008 12:30 PM
  Subject: Re: [Flashcoders] AS3 - Upload image problem


  http://www.tink.ws/blog/a-round-trip-with-filereference/

  SJM - Flash wrote:
   Hi guys im having problems with uploading an image, i cant seam to get
it to work! Most of the code is from the help files but still no joy! Any
ideas...
  
   public function uploadImage( ev:MouseEvent ):void
 {
  uploadURL = new URLRequest();
   uploadURL.url = _mainClass._imgUploadURL;
   file = new FileReference();
   file.browse(getTypes());   
   trace(uploadImage:  + ev);
 }
  
  
   The above trace outouts this...
  
   uploadImage: [MouseEvent type=click bubbles=true cancelable=false
eventPhase=3 localX=16 localY=4 stageX=95.65 stageY=236.72
relatedObject=null ctrlKey=false altKey=false shiftKey=false delta=0]]
  
   As far as i can tell it does not go any further into the code below!
  
   private function getTypes():Array {
   var allTypes:Array = new Array(getImageTypeFilter());
   return allTypes;
   }
  
  
   private function getImageTypeFilter():FileFilter {
   return new FileFilter(Images (*.jpg, *.jpeg),
*.jpg;*.jpeg;);
   }
  
  
   private function cancelHandler(ev:Event):void {
   trace(cancelHandler:  + ev);
   }
  
   private function completeHandler(ev:Event):void {
   trace(completeHandler:  + ev);
   }
  
   private function uploadCompleteDataHandler(ev:Event):void {
   trace(uploadCompleteData:  + ev);
   _xmlClass.xmlLoader(bannerInfo.xml);
   _xmlClass.addEventListener(Event.COMPLETE,
_mainClass.afterUploadXML);
   }
  
   private function httpStatusHandler(ev:HTTPStatusEvent):void {
   trace(httpStatusHandler:  + ev);
   }
   
   private function ioErrorHandler(ev:IOErrorEvent):void {
   trace(ioErrorHandler:  + ev);
   }
  
   private function openHandler(ev:Event):void {
   trace(openHandler:  + ev);
   }
  
   private function progressHandler(ev:ProgressEvent):void {
   var file:FileReference = FileReference(ev.target);
   trace(progressHandler name= + file.name +  bytesLoaded=
+ ev.bytesLoaded +  bytesTotal= + ev.bytesTotal);
   }
  
   private function selectHandler(event:Event):void {
   var file:FileReference = FileReference(event.target);
   trace(selectHandler: name= + file.name +  URL= +
uploadURL.url);
   file.upload(uploadURL);
   }  
   ___
   Flashcoders mailing list
   Flashcoders@chattyfig.figleaf.com
   http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
  
  
 

  -- 

  Glen Pike
  01326 218440
  www.glenpike.co.uk http://www.glenpike.co.uk

  ___
  Flashcoders mailing list
  Flashcoders@chattyfig.figleaf.com
  http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

d


___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] AS3 - Upload image problem

2008-05-20 Thread SJM - Flash
Thanks Glen ive added listener and seams to be ok! Need to test a live version 
now tho!
  - Original Message - 
  From: Glen Pike 
  To: Flash Coders List 
  Sent: Tuesday, May 20, 2008 12:53 PM
  Subject: Re: [Flashcoders] AS3 - Upload image problem


  Apologies, it is.

  You need to add listeners for all the events that FileReference dispatches.

  At a minimum you need to listen for the select event to begin uploading:


  file.addEventListener(Event.SELECT, selectHandler);


  Here is  a link to the Flex 2 langref with an example that adds all the 
  listeners - check the Flash one if you are using CS3, but the class 
  should be the same, so you may be okay.

  
http://livedocs.adobe.com/flex/201/langref/flash/net/FileReference.html#includeExamplesSummary

  HTH

  Glen



  SJM - Flash wrote:
   Glen is that not for AS2?
 - Original Message - 
 From: Glen Pike 
 To: Flash Coders List 
 Sent: Tuesday, May 20, 2008 12:30 PM
 Subject: Re: [Flashcoders] AS3 - Upload image problem
  
  
 http://www.tink.ws/blog/a-round-trip-with-filereference/
  
 SJM - Flash wrote:
  Hi guys im having problems with uploading an image, i cant seam to get 
it to work! Most of the code is from the help files but still no joy! Any 
ideas...
 
  public function uploadImage( ev:MouseEvent ):void
{
 uploadURL = new URLRequest();
  uploadURL.url = _mainClass._imgUploadURL;
  file = new FileReference();
  file.browse(getTypes());   
  trace(uploadImage:  + ev);
}
 
 
  The above trace outouts this...
 
  uploadImage: [MouseEvent type=click bubbles=true cancelable=false 
eventPhase=3 localX=16 localY=4 stageX=95.65 stageY=236.72 
relatedObject=null ctrlKey=false altKey=false shiftKey=false delta=0]]
 
  As far as i can tell it does not go any further into the code below!
 
  private function getTypes():Array {
  var allTypes:Array = new Array(getImageTypeFilter());
  return allTypes;
  }
 
 
  private function getImageTypeFilter():FileFilter {
  return new FileFilter(Images (*.jpg, *.jpeg), 
*.jpg;*.jpeg;);
  }
 
 
  private function cancelHandler(ev:Event):void {
  trace(cancelHandler:  + ev);
  }
 
  private function completeHandler(ev:Event):void {
  trace(completeHandler:  + ev);
  }
 
  private function uploadCompleteDataHandler(ev:Event):void {
  trace(uploadCompleteData:  + ev);
  _xmlClass.xmlLoader(bannerInfo.xml);
  _xmlClass.addEventListener(Event.COMPLETE, 
_mainClass.afterUploadXML);
  }
 
  private function httpStatusHandler(ev:HTTPStatusEvent):void {
  trace(httpStatusHandler:  + ev);
  }
  
  private function ioErrorHandler(ev:IOErrorEvent):void {
  trace(ioErrorHandler:  + ev);
  }
 
  private function openHandler(ev:Event):void {
  trace(openHandler:  + ev);
  }
 
  private function progressHandler(ev:ProgressEvent):void {
  var file:FileReference = FileReference(ev.target);
  trace(progressHandler name= + file.name +  bytesLoaded= 
+ ev.bytesLoaded +  bytesTotal= + ev.bytesTotal);
  }
 
  private function selectHandler(event:Event):void {
  var file:FileReference = FileReference(event.target);
  trace(selectHandler: name= + file.name +  URL= + 
uploadURL.url);
  file.upload(uploadURL);
  }  
  ___
  Flashcoders mailing list
  Flashcoders@chattyfig.figleaf.com
  http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
 
 

  
 -- 
  
 Glen Pike
 01326 218440
 www.glenpike.co.uk http://www.glenpike.co.uk
  
 ___
 Flashcoders mailing list
 Flashcoders@chattyfig.figleaf.com
 http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
   ___
   Flashcoders mailing list
   Flashcoders@chattyfig.figleaf.com
   http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
  
  
 

  -- 

  Glen Pike
  01326 218440
  www.glenpike.co.uk http://www.glenpike.co.uk

  ___
  Flashcoders mailing list
  Flashcoders@chattyfig.figleaf.com
  http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] AS3 - Upload image problem

2008-05-20 Thread SJM - Flash
Cheers Jimbo, i downloaded this file to see what i was missing from mine, added 
the listenor Glen was taling about and alls well! :o)
  - Original Message - 
  From: Jimbo 
  To: flashcoders@chattyfig.figleaf.com 
  Sent: Tuesday, May 20, 2008 1:02 PM
  Subject: Re: [Flashcoders] AS3 - Upload image problem


  Here's one if you don't want to roll your own- it's really easy to customize:
  
http://www.flepstudio.org/english/utilities/free-utilities/flash-cs3-uploader-_-free-utility-2007073189.html

  jimbo

  *** REPLY SEPARATOR  ***

  On 5/20/2008 at 12:44 PM SJM - Flash wrote:

  Glen is that not for AS2?
- Original Message - 
From: Glen Pike 
To: Flash Coders List 
Sent: Tuesday, May 20, 2008 12:30 PM
Subject: Re: [Flashcoders] AS3 - Upload image problem


http://www.tink.ws/blog/a-round-trip-with-filereference/

SJM - Flash wrote:
 Hi guys im having problems with uploading an image, i cant seam to get
  it to work! Most of the code is from the help files but still no joy! Any
  ideas...

 public function uploadImage( ev:MouseEvent ):void
   {
uploadURL = new URLRequest();
 uploadURL.url = _mainClass._imgUploadURL;
 file = new FileReference();
 file.browse(getTypes());   
 trace(uploadImage:  + ev);
   }


 The above trace outouts this...

 uploadImage: [MouseEvent type=click bubbles=true cancelable=false
  eventPhase=3 localX=16 localY=4 stageX=95.65 stageY=236.72
  relatedObject=null ctrlKey=false altKey=false shiftKey=false delta=0]]

 As far as i can tell it does not go any further into the code below!

 private function getTypes():Array {
 var allTypes:Array = new Array(getImageTypeFilter());
 return allTypes;
 }


 private function getImageTypeFilter():FileFilter {
 return new FileFilter(Images (*.jpg, *.jpeg),
  *.jpg;*.jpeg;);
 }


 private function cancelHandler(ev:Event):void {
 trace(cancelHandler:  + ev);
 }

 private function completeHandler(ev:Event):void {
 trace(completeHandler:  + ev);
 }

 private function uploadCompleteDataHandler(ev:Event):void {
 trace(uploadCompleteData:  + ev);
 _xmlClass.xmlLoader(bannerInfo.xml);
 _xmlClass.addEventListener(Event.COMPLETE,
  _mainClass.afterUploadXML);
 }

 private function httpStatusHandler(ev:HTTPStatusEvent):void {
 trace(httpStatusHandler:  + ev);
 }
 
 private function ioErrorHandler(ev:IOErrorEvent):void {
 trace(ioErrorHandler:  + ev);
 }

 private function openHandler(ev:Event):void {
 trace(openHandler:  + ev);
 }

 private function progressHandler(ev:ProgressEvent):void {
 var file:FileReference = FileReference(ev.target);
 trace(progressHandler name= + file.name +  bytesLoaded=
  + ev.bytesLoaded +  bytesTotal= + ev.bytesTotal);
 }

 private function selectHandler(event:Event):void {
 var file:FileReference = FileReference(event.target);
 trace(selectHandler: name= + file.name +  URL= +
  uploadURL.url);
 file.upload(uploadURL);
 }  
 ___
 Flashcoders mailing list
 Flashcoders@chattyfig.figleaf.com
 http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


   

-- 

Glen Pike
01326 218440
www.glenpike.co.uk http://www.glenpike.co.uk

___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
  ___
  Flashcoders mailing list
  Flashcoders@chattyfig.figleaf.com
  http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

  d


  ___
  Flashcoders mailing list
  Flashcoders@chattyfig.figleaf.com
  http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] AS3 - Upload image problem

2008-05-20 Thread Glen Pike

Hi,
  
   If you are using PHP, remember to use the getimagesize() function to 
add a bit of security to your upload script - if someone is trying to 
spoof the image, it can add an extra level of security - possibly not 
foolproof, but pretty good.


   It's something like getimagesize($_FILES['myFileName']['tmpname']) 
for normal HTML forms, maybe slightly different for Flash - look at some 
of the Flash tut's for this.


   HTH

   Glen

SJM - Flash wrote:

Thanks Glen ive added listener and seams to be ok! Need to test a live version 
now tho!
  - Original Message - 
  From: Glen Pike 
  To: Flash Coders List 
  Sent: Tuesday, May 20, 2008 12:53 PM

  Subject: Re: [Flashcoders] AS3 - Upload image problem


  Apologies, it is.

  You need to add listeners for all the events that FileReference dispatches.

  At a minimum you need to listen for the select event to begin uploading:


  file.addEventListener(Event.SELECT, selectHandler);


  Here is  a link to the Flex 2 langref with an example that adds all the 
  listeners - check the Flash one if you are using CS3, but the class 
  should be the same, so you may be okay.


  
http://livedocs.adobe.com/flex/201/langref/flash/net/FileReference.html#includeExamplesSummary

  HTH

  Glen



  SJM - Flash wrote:
   Glen is that not for AS2?
 - Original Message - 
 From: Glen Pike 
 To: Flash Coders List 
 Sent: Tuesday, May 20, 2008 12:30 PM

 Subject: Re: [Flashcoders] AS3 - Upload image problem
  
  
 http://www.tink.ws/blog/a-round-trip-with-filereference/
  
 SJM - Flash wrote:
  Hi guys im having problems with uploading an image, i cant seam to get 
it to work! Most of the code is from the help files but still no joy! Any ideas...
 
  public function uploadImage( ev:MouseEvent ):void
{
 uploadURL = new URLRequest();
  uploadURL.url = _mainClass._imgUploadURL;
  file = new FileReference();
  file.browse(getTypes());   
  trace(uploadImage:  + ev);

}
 
 
  The above trace outouts this...
 
  uploadImage: [MouseEvent type=click bubbles=true cancelable=false 
eventPhase=3 localX=16 localY=4 stageX=95.65 stageY=236.72 relatedObject=null 
ctrlKey=false altKey=false shiftKey=false delta=0]]
 
  As far as i can tell it does not go any further into the code below!
 
  private function getTypes():Array {
  var allTypes:Array = new Array(getImageTypeFilter());
  return allTypes;
  }
 
 
  private function getImageTypeFilter():FileFilter {
  return new FileFilter(Images (*.jpg, *.jpeg), 
*.jpg;*.jpeg;);
  }
 
 
  private function cancelHandler(ev:Event):void {
  trace(cancelHandler:  + ev);
  }
 
  private function completeHandler(ev:Event):void {
  trace(completeHandler:  + ev);
  }
 
  private function uploadCompleteDataHandler(ev:Event):void {
  trace(uploadCompleteData:  + ev);
  _xmlClass.xmlLoader(bannerInfo.xml);
  _xmlClass.addEventListener(Event.COMPLETE, 
_mainClass.afterUploadXML);
  }
 
  private function httpStatusHandler(ev:HTTPStatusEvent):void {
  trace(httpStatusHandler:  + ev);
  }
  
  private function ioErrorHandler(ev:IOErrorEvent):void {

  trace(ioErrorHandler:  + ev);
  }
 
  private function openHandler(ev:Event):void {
  trace(openHandler:  + ev);
  }
 
  private function progressHandler(ev:ProgressEvent):void {
  var file:FileReference = FileReference(ev.target);
  trace(progressHandler name= + file.name +  bytesLoaded= + 
ev.bytesLoaded +  bytesTotal= + ev.bytesTotal);
  }
 
  private function selectHandler(event:Event):void {
  var file:FileReference = FileReference(event.target);
  trace(selectHandler: name= + file.name +  URL= + 
uploadURL.url);
  file.upload(uploadURL);
  }  
  ___

  Flashcoders mailing list
  Flashcoders@chattyfig.figleaf.com
  http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
 
 

  
 -- 
  

 Glen Pike
 01326 218440
 www.glenpike.co.uk http://www.glenpike.co.uk
  
 ___
 Flashcoders mailing list
 Flashcoders@chattyfig.figleaf.com
 http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
   ___
   Flashcoders mailing list
   Flashcoders@chattyfig.figleaf.com
   http://chattyfig.figleaf.com