Truncated response on DataEvent.UPLOAD_COMPLETE_DATA

Hello,
We are developing an mobile AIR application, using the Flex 4.6 SDK, which uploads a file to a server and then relies on getting some information (the upload’s ID) from the server’s response.
It all works fine when running through the AIR simulator, but when we run the app on an iPhone or an iPad, the server’s response after the upload has finished seems truncated.
We weren’t sure where the response might get truncated, so we tried Wireshark to compare the packets that come back from the server for a “good” and for a truncated response and they seem to be exactly the same in size.
This is an example code of what we’re trying to do:
public function uploadFileToServer( _filePath : String ) : void
          var file : File = new File( _filePath );
          var requestText : String = “...”;
          var request : URLRequest = new URLRequest( requestText );
          request.method = URLRequestMethod.POST;
          request.contentType = "multipart/form-data";
file.addEventListener( DataEvent.UPLOAD_COMPLETE_DATA, handleFileUploadComplete );
          file.upload( request, "File1" );
in handleFileUploadComplete is where the DataEvent’s data is truncated on a mobile device, but not when the application runs through the simulator.
The “good” response isn’t large and is no more than 130 symbols. On a mobile device it always gets truncated to 48 symbols.
Assuming that the server sends exactly the same response each time (or so it seems when looking at the communication with Wireshark), is there a way to track what happens to it between its arrival and what comes in on the DataEvent.UPLOAD_COMPLETE_DATA event?
Thank you in advance.
DiaDraw.com

Hi Sanika and thank you for responding so quickly!
I should have provided these answers in my initial question - thanks for the reminder:
1. The file does get uploaded successfully to the server every time (including when running the app on the iPhone and the iPad).
2. There are listeners in the code to the rest of the events (securityError, httpStatus, httpResponseStatus and ioError) - I omitted them from the example to avoid clutter.
3. None of the error events fire.
I'll bundle an application for reproducing the problem and will file a bug report.
Thank you,
DiaDraw.com

Similar Messages

  • Problem with Socket Client - Intermittent Truncated Response in AIX

    {color:#0000ff}Hi guru
    I have written on Socket Client method below to send request byte[] to Host and receive response byte[] from Host.
    For this particular response, I'm expecting Host to return me byte[] with length 2274.
    My problem is intermittently I received truncated message byte[] from Host with length only 1392. Sometimes I received full 2274 message, sometimes I received 1392 length. I tested in continual of 10 times by sending the same request to host, intermittently received truncated response message.
    My real problem is that this only happened in {color:#ff0000}AIX {color}machine. With the same class, I tested on {color:#ff0000}Windows {color}platform and i received full response message byte[] with 2274 lenght always. Therefore, im counting out the possibilities that Host might send me truncated message.
    Can anyone pls help to tell me how should I proceed to troubleshoot this problem in AIX? Is possible for me to trace what coming in?
    {color}
    public byte[] sendToHost(byte[] requestMessage, String requestId, String localTxnCode) throws Exception {
    BufferedInputStream bis = null;
    BufferedOutputStream bos = null;
    long startTime = 0;
    long elapsed = 0;
    try {
    LogManager.log(LogManager.DEBUG, Constants.DEFAULT_LOGGER_NAME, requestId, "[" + localTxnCode + "] To connect and send message to Host hostAddr=[" + hostAddr + "], hostPort=[" + hostPort
    + "]");
    startTime = System.currentTimeMillis();
    hostSocket = new Socket(InetAddress.getByName(hostAddr), hostPort);
    hostSocket.setSoTimeout(timeOut);
    byte responseData[] = new byte[4096];
    bis = new BufferedInputStream(hostSocket.getInputStream());
    bos = new BufferedOutputStream(hostSocket.getOutputStream());
    bos.write(requestMessage);
    bos.flush();
    int length = bis.read(responseData);
    elapsed = System.currentTimeMillis() - startTime;
    ARBAdapterUtil.log(LogManager.DEBUG, Constants.DEFAULT_LOGGER_NAME, requestId, "[" + localTxnCode + "] Received message from Host length=[" + length + "]");
    // The response byte must not be 4096 everytime
    byte[] returnByte = new byte[length];
    for (int i = 0; i < length; i++) {
    returnByte[i] = responseData;
    return returnByte;
    } catch (BindException b) {
    elapsed = System.currentTimeMillis() - startTime;
    throw new SocketException("Socket Exception: BindException IP=" + hostAddr + " PORT=" + hostPort + " Error type=" + b.getClass().getName() + " Error message=" + b.getMessage());
    } catch (ConnectException c) {
    elapsed = System.currentTimeMillis() - startTime;
    throw new SocketException("Socket Exception: ConnectException IP=" + hostAddr + " PORT=" + hostPort + " Error type=" + c.getClass().getName() + " Error message=" + c.getMessage());
    } catch (NoRouteToHostException nrth) {
    elapsed = System.currentTimeMillis() - startTime;
    throw new SocketException("Socket Exception: NoRouteToHostException IP=" + hostAddr + " PORT=" + hostPort + " Error type=" + nrth.getClass().getName() + " Error message="+ nrth.getMessage());
    } catch (SocketTimeoutException se) {
    elapsed = System.currentTimeMillis() - startTime;
    throw new SocketTimeoutException("Socket Exception: SocketTimeoutException IP=" + hostAddr + " PORT=" + hostPort + " Error type=" + se.getClass().getName() + " Error message=" + se.getMessage());
    } catch (SocketException s) {
    elapsed = System.currentTimeMillis() - startTime;
    throw new SocketException("Socket Exception: SocketException IP=" + hostAddr + " PORT=" + hostPort + " Error type=" + s.getClass().getName() + " Error message=" + s.getMessage());
    } catch (Exception e) {
    elapsed = System.currentTimeMillis() - startTime;
    throw new Exception("Unknown Exception: Exception IP=" + hostAddr + " PORT=" + hostPort + "Error type=" + e.getClass().getName() + " Error message=" + e.getMessage());
    } finally {
    try {
    ARBAdapterUtil.log(LogManager.INFO, Constants.DEFAULT_LOGGER_NAME, requestId, "ARBConnection.sendToHost() [" + localTxnCode + "] Time Elapsed via Socket in millisecond = [" + elapsed + "]");
    if (bis != null) {
    bis.close();
    bis = null;
    if (bos != null) {
    bos.close();
    bos = null;
    } catch (Exception e) {
    LogManager.log(LogManager.ERROR, Constants.DEFAULT_LOGGER_NAME, requestId, "ARBConnection.sendToHost() [" + localTxnCode + "] Exception during closing BufferedInputStream and BufferedOutputStream");

    I tried to use DataInputStream.readFully(byte[]). However, I could not retrieve a single byte from Host. It won't return until it fills the buffer, or EOS occurs. Isn't that what you wanted?
    You need to believe it here. Either the sending application or Java or the sending TCP stack or the intervening routers or the receiving TCP stack or Java or the receiver can break up the transmission into 1 byte reads and there is nothing you can do about it at the receiver except what I said. BufferedInputStream will mask the effect to some extent but you still have to code under that assumption. You don't have any choice about this.

  • Is fileReference DataEvent.UPLOAD_COMPLETE_DATA 100% guaranteed to execute a service call?

    I am making a file upload system and I would like to ask one thing about it. Here is how it works at the moment:
    1. You select the file and upload it with the fileReference.upload(path/to/upload.php).
    2. On DataEvent.UPLOAD_COMPLETE_DATA the upload.php returns a xml data with file properties like new fileName, filePath, fileUrl etc
    which I pass to a php service which writes the data to a database along with other stuff.
    My question here is: Is it possible for someone to interupt this chain of events. By this I mean - is it possible for the file to get uploaded but the service which writes the data to the database to never be executed. For example if the user closes the browser at 100% video upload right after it's uploaded and right before the service is called? This would cause the file to be uploaded and the system wouldn't know about it and the server might get overloaded with files that don't exist in the system.
    Help please!

    I guess the question to this answer is like asking if on web browser's unload event you call ExternalInterface to call a function in flash which executes an http request before closing. I am not sure that it's the same thing though!
    Would both examples work ? Is it 100% guaranteed that they won't sometimes fail to execute?

  • FileReference.upload response is truncated on Mac

    I have flash as3 code that will upload a file to my server using FileReference.upload but when receiving the DataEvent.UPLOAD_COMPLETE_DATA event * on MAC only *, I find that event.data will get truncated after a certain number of bytes/characters (looks to be about 2400 Bytes). I know that my server is returning more data than this because I can see the raw response using an HTTP sniffer program. Is there a reason my response data is getting truncated on macs and is there anything I can do to avoid this truncation?
    My server side code is running on ASP.NET and IIS if that is relevant. The Content-Length HTTP Header value also appears to be set correctly. This looks to work on windows (firefox 3.6, chrome, and IE) but fails consistently on mac (firefox, chrome, safari).
    Any ideas?

    I have flash as3 code that will upload a file to my server using FileReference.upload but when receiving the DataEvent.UPLOAD_COMPLETE_DATA event * on MAC only *, I find that event.data will get truncated after a certain number of bytes/characters (looks to be about 2400 Bytes). I know that my server is returning more data than this because I can see the raw response using an HTTP sniffer program. Is there a reason my response data is getting truncated on macs and is there anything I can do to avoid this truncation?
    My server side code is running on ASP.NET and IIS if that is relevant. The Content-Length HTTP Header value also appears to be set correctly. This looks to work on windows (firefox 3.6, chrome, and IE) but fails consistently on mac (firefox, chrome, safari).
    Any ideas?

  • Getting the response from a FileReference upload

    This question is about the "upload" method of the
    FileReference class.
    Is there any way to read the HTTP response after a file
    upload is complete? For example, a user uploads an file to a
    server. The server saves the file and assigns it an ID. The server
    then writes the ID to the HTTP response. How does the client read
    that response?

    inlineblue wrote:
     This was kicked around a while back in the Flexcoders list.
    Everyone agrees this would be very useful, but not currently
    available. Sigh.
    Flexcoders said what?  (Am I missing something? Ahh - the date of the original post...)
    fileReference.addEventListener(DataEvent.UPLOAD_COMPLETE_DATA, uploadComplete);
    private function uploadComplete(event:DataEvent):void {
         trace(event.data);
    getWriter() or getOutputStream() on the servlet response to send "stuff" back...

  • Upload File and get XML response

    Hi,
    When uploading a file using FileReference's upload method, is
    there a way to get some information back from the server other than
    the 'complete' event. I need more information other than complete
    with no HTTP errors.
    For example, I upload a zip file, do a bit of processing on
    the zip (check for some information within the zip file ) then I
    want to send some XML back to the requesting actionscript... like
    the 'result' handler for HTTPService. Is this possible?
    ::server script pseudo::
    get Filedata (zip file) from post
    write Filedata to disk
    do stuff to zip file contents
    spit out some XML (this xml would be consumed by
    actionscript)
    I have not been able to figure out how to do this using
    FileReference.

    Well I'm an idiot
    The answer was right there in the docs...
    The FileReference object will dispatch a uploadCompleteData
    event that you can listen for, and when it fires use the data
    property to extract the server's response
    _fileRef.addEventListener(DataEvent.UPLOAD_COMPLETE_DATA,
    onUploadCompleteData);
    var mUploadURLRequest:URLRequest = new URLRequest( _uploadURL
    _fileRef.upload(mUploadURLRequest);
    private function onUploadCompleteData( e : DataEvent ) : void
    var data : Object = e.data;
    trace( ObjectUtil.toString(data) );
    }

  • Uploading csv files and reading them from server

    I want to read a csv file.From Flex i am able to select the
    file but when i pass it to the server using struts
    FileUploadInterceptor , am not able to pass the file to the
    server.FileUploadInterceptor in struts2 processes the request only
    if its instance of MultiPartRequestWrapper.Is there any way in Flex
    where i can pass the request as a instance of this.Is there any
    other way in which i can read the file from the server after
    uploading it through flex.Code is as follows :
    1)MXML File :
    ?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="
    http://www.adobe.com/2006/mxml"
    layout="absolute">
    <mx:Script>
    <![CDATA[
    import ImportData;
    import flash.net.FileReference;
    import flash.net.FileFilter;
    import flash.events.IOErrorEvent;
    [Bindable] var fileRef:FileReference = new FileReference();
    private function openFileDialog():void{
    fileRef.addEventListener(Event.SELECT, selectHandler);
    fileRef.addEventListener(Event.COMPLETE, completeHandler);
    fileRef.addEventListener(DataEvent.UPLOAD_COMPLETE_DATA
    ,uploadCompleteHandler);
    fileRef.addEventListener(IOErrorEvent.IO_ERROR,onIOError);
    try{
    var textTypes:FileFilter = new FileFilter("Text Files
    (*.txt,*.csv)","*.txt;*.csv");
    var allTypes:Array = new Array(textTypes);
    //var success:Boolean = fileRef.browse();
    var success:Boolean = fileRef.browse(allTypes);
    catch(error:Error){
    trace("Unable to browse for files.");
    private function onIOError(event:IOErrorEvent):void {
    trace("In here"+event.text);
    trace("In here"+event.toString());
    // when a file is selected you upload the file to the upload
    script on the server
    private function selectHandler(event:Event):void{
    //var request:URLRequest = new URLRequest("/importAction");
    var request:URLRequest = new URLRequest("
    http://localhost:8080/pack1/importAction.action");
    try
    fileRef.upload(request);
    catch (error:Error)
    trace("Unable to upload file.");
    private function completeHandler(event:Event):void{
    trace("uploaded");
    // dispatched when file has been uploaded to the server
    script and a response is returned from the server
    // event.data contains the response returned by your server
    script
    public function uploadCompleteHandler(event:DataEvent):void
    trace("uploaded... response from server: \n" +
    String(event.data));
    ]]>
    </mx:Script>
    <mx:Button label="Import" id="importBtn"
    click="openFileDialog()" height="20" width="90"
    styleName="buttonsOnSearchBar"/>
    <mx:ComboBox x="23" y="44" borderColor="#ff0000"
    themeColor="#ff0000"></mx:ComboBox>
    </mx:Application>
    2)struts.xml file
    <struts>
    <package name="pack1"
    extends="struts-default,json-default">
    <global-results>
    <result name="error" type="json"></result>
    </global-results>
    <global-exception-mappings>
    <exception-mapping result="error"
    exception="java.lang.Throwable"/>
    </global-exception-mappings>
    <action name="importAction"
    class="routing.ImportAction">
    <interceptor-ref name="fileUpload"/>
    <interceptor-ref name="basicStack"/>
    <result name="success" type="json"></result>
    </action>
    </package>
    </struts>
    3)Action Class
    package com.om.dh.orderrouting.action;
    import java.io.BufferedReader;
    import java.io.File;
    import java.io.FileNotFoundException;
    import java.io.FileReader;
    import java.util.ArrayList;
    import java.util.StringTokenizer;
    import org.apache.log4j.Logger;
    import com.opensymphony.xwork2.ActionSupport;
    public class ImportAction extends ActionSupport{
    private String contentType;
    private File upload;
    private String fileName;
    private String caption;
    private static final Logger logger =
    Logger.getLogger(ImportAction.class);
    @Override
    public String execute() throws Exception {
    * Read File Line by Line.. If the file has more than one
    word separated by comma
    * return error.
    ArrayList<String> symbolList = new
    ArrayList<String>();
    try{
    BufferedReader reader = new BufferedReader(new
    FileReader(upload));
    String line =null;
    String symbol=null;
    while((line=reader.readLine())!=null){
    StringTokenizer tokenizer = new StringTokenizer(line,"\t");
    symbol = tokenizer.nextToken();
    if(symbol!=null) symbol = symbol.trim();
    if(symbol.length()>0)
    symbolList.add(symbol);
    }catch(FileNotFoundException fne){
    if(logger.isDebugEnabled())
    logger.debug("File NotFount ", fne);
    for(String symbol1:symbolList)
    System.out.print(symbol1+" ");
    return SUCCESS;
    public String getUploadFileName() {
    return fileName;
    public void setUploadFileName(String fileName) {
    this.fileName = fileName;
    public String getUploadContentType() {
    return contentType;
    public void setUploadContentType(String contentType) {
    this.contentType = contentType;
    public File getUpload() {
    return upload;
    public void setUpload(File upload) {
    this.upload = upload;
    public String getCaption() {
    return caption;
    public void setCaption(String caption) {
    this.caption = caption;
    public String input() throws Exception {
    return SUCCESS;
    public String upload() throws Exception {
    return SUCCESS;

    quote:
    Originally posted by:
    ived
    tried this but does not work...
    var request:URLRequest = new URLRequest("
    http://localhost:8080/pack1/importAction.action");
    request.contentType="multipart/form-data";
    in the interceptor it expects the request to be instanceof
    MultiPartRequestWrapper...
    Further the document says that FileReference.upload() and
    FileReference.download() methods do not support the
    URLRequest.contentType and URLRequest.requestHeaders parameters.
    Any help ??

  • Pass variables?

    Hello!
    I have this code and I'm trying to upload files to the server. I'm using .NET(C#) now I wonder how I can pass the filename, path and so on to the aspx-page?
    var fileRef:FileReferenceList = new FileReferenceList();
    fileRef = new FileReferenceList();
    var uploadURL:URLRequest = new URLRequest();
    var uploadPhotoString:String = "http://localhost/cs/upload.aspx";
    uploadURL.url = uploadPhotoString;
    function fileSelectHandler(event:Event):void{
    for each(var fileToUpload:FileReference in fileRef.fileList){
      uploadSingleFile(fileToUpload);
      lblUpload.htmlText = fileToUpload.name + "<br />";
    function uploadSingleFile(file:FileReference):void{
    file.upload(uploadURL);
    file.addEventListener(Event.COMPLETE, completeHandler);
    function completeHandler(event:Event):void{
    trace("Uppladdningen lyckades");
    btnUpload.addEventListener(MouseEvent.MOUSE_DOWN, reportClick);
    function reportClick(event:MouseEvent) {
    fileRef.browse();
    fileRef.addEventListener(Event.SELECT, fileSelectHandler);
    fileRef.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler);
    function ioErrorHandler(event:IOErrorEvent):void {
            trace("Det uppstod ett IO fel");

    Use some thing like following:
    private function upload()
         var uploadPath:String = "<Enter aspx page path here>";
        var requestFileUpload:URLRequest = new URLRequest(uploadPath);
        var vars:URLVariables = new URLVariables(); //This might help you
        vars.fileName = "<Enter the file name here>";
        vars.XYZ ="<Enter value for XYZ here>";
    //Append all your variables in "vars" object to your request
    requestFileUpload.data = vars
    //Use this to track Upload errors  
    fileRef.addEventListener(IOErrorEvent.IO_ERROR, uploadError);
        try
              fileRef.upload(requestFileUpload,"fileContent");
        catch(error:Error)
         trace(error);
         //Use this to track when uploading is complete
        fileRef.addEventListener(Event.COMPLETE, uploadingFinished);
         //Use this to receive the response
        fileRef.addEventListener(DataEvent.UPLOAD_COMPLETE_DATA, uploadCompleteData); //This might help you

  • Warnings in FileReference - can not find the cause

    I'm trying to make a loader of a few photos (use FileReference). I get the warnings, but I do not know the reason for their appearance.
    warning: unable to bind to property 'fr' on class 'Object' (class is not an IEventDispatcher)
    warning: unable to bind to property 'name' on class 'flash.net::FileReference'
    warning: unable to bind to property 'data' on class 'flash.net::FileReference'
    warning: unable to bind to property 'fr' on class 'Object' (class is not an IEventDispatcher)
    warning: unable to bind to property 'name' on class 'flash.net::FileReference'
    warning: unable to bind to property 'data' on class 'flash.net::FileReference'
    CODE:
    import mx.events.CollectionEvent;
    import flash.net.FileReferenceList;
    import mx.collections.ArrayCollection;
    [Bindable]
    private var photos:ArrayCollection = new ArrayCollection;
    private var frList:FileReferenceList = new FileReferenceList;
    private function init():void
    photos.addEventListener(CollectionEvent.COLLECTION_CHANGE,function():void
    startUploadButton.enabled = (photos.length>0);
    clearPhotosButton.enabled = (photos.length>0);
    frList.addEventListener(Event.SELECT,addPhotos);
    private function selectPhotos():void
    var fileFilter:FileFilter = new FileFilter("Images jpeg","*.jpg;*.jpeg");
    frList.browse([fileFilter]);
    private function addPhotos(e:Event):void
    for (var i:uint = 0; i < frList.fileList.length; i++)
    var elem:Object = new Object;
    elem.fr = FileReference(frList.fileList[i]);
    elem.fr.load();
    elem.fr.addEventListener(Event.COMPLETE,refreshThumb);
    photos.addItem(elem);
    private function refreshThumb(e:Event):void
    photosList.invalidateList();
    public function clearPhoto(data:Object):void
    photos.removeItemAt(photos.getItemIndex(data));
    photosList.invalidateList();
    private function startUpload():void
    photosProgressContainer.visible = true;
    var request:URLRequest = new URLRequest();
    request.url = "http://localhost/tempLoader-debug/upload.php";
    var fr:FileReference = photos.getItemAt(0).fr;
    fr.cancel();
    fr.addEventListener(ProgressEvent.PROGRESS,uploadProgress);
    fr.addEventListener(DataEvent.UPLOAD_COMPLETE_DATA,uploadComplete);
    fr.upload(request);
    private function uploadProgress(e:ProgressEvent):void
    photosProgress.setProgress(e.bytesLoaded,e.bytesTotal);
    private function uploadComplete(e:DataEvent):void
    photos.removeItemAt(0);
    photosList.invalidateList();
    if (photos.length > 0)
    startUpload();
    else
    photosProgressContainer.visible = false;

    In my opinion this is the line that is causing you the warning:
    <mx:Image source="{data.fr.data}" maxWidth="100" maxHeight="75"
    horizontalAlign="center" verticalAlign="middle" />
    That means that data should be a custom binable object and fr should be another
    custom bindable object.
    like
    public class BindableData
        public var fr:BindableData2;
    public class BindableData2
        public var data:String;
    I am not sure though what you are trying to do though, but I assume you try top
    load an image from your disk. This link will help you:
    view source enabled...
    http://www.everythingflex.com/flex3/flexcampItaly/
    the blog post ...
    http://blog.everythingflex.com/2009/09/08/flexcamp-presentation-filereference-load-part-1- of-3/
    C
    From: Astraport2012 <[email protected]>
    To: Ursica Claudiu <[email protected]>
    Sent: Sun, October 3, 2010 3:07:57 PM
    Subject: Re: Warnings in FileReference - can not find the cause
    I found the solution to the first part of the warning. Only need to modify the
    object as ObjectProxy
    public var elem:ObjectProxy = new ObjectProxy;
    But with the second part is still a problem (warning: unable to bind to property
    'name' on class 'flash.net::FileReference'
    warning: unable to bind to property 'data' on class 'flash.net::FileReference').
    I do not fully describe the problem in the first message. The main application
    calls the component and passes it parameters. They cause errors.
    It is this component photoThumb.mxml:
    <?xml version="1.0" encoding="utf-8"?>
       width="120" height="110"
       backgroundColor="#FFFFFF" backgroundAlpha="0"
       rollOver="{controls.visible=true;}" rollOut="{controls.visible=false;}">
    <mx:Image source="@Embed('t1.png')" width="100%" height="100%" alpha="0"
    horizontalAlign="center" verticalAlign="middle"/>
    <mx:VBox width="100%" height="90" y="5" horizontalAlign="center" >
    <mx:Image source="{data.fr.data}" maxWidth="100" maxHeight="75"
    horizontalAlign="center" verticalAlign="middle" />
    </mx:VBox>
    <mx:Label text="{data.fr.name}" width="118" truncateToFit="false" bottom="0"
    textAlign="center" />
    <mx:VBox id="controls" visible="false" y="65" right="10" horizontalAlign="right"
    >
    <mx:Button label="X" click="parentDocument.clearPhoto(data)" fontSize="6"
    width="30" height="15" />
    </mx:VBox>
    </mx:Canvas

  • Problems while uploading files using the FileReference API

    I've built an image uploader module in Flex using the FileReference API and PHP.
    While this works perfect for images upto 1 MB, What I'm noticing is that for images greater that 1 MB even after the Event.COMPLETE  has triggered, the file hasn't yet been uploaded into the folder.. its only after a couple of seconds or minutes after the Event.COMPLETE,  that the image actually shows up in the FTP folder. Morever I also noticed that for such files the DataEvent.UPLOAD_COMPLETE_DATA that we are using to get feedback from PHP never gets called.
    I thought it would be related to the PHP script getting timed out... but the PHP script does get executed and the images do show up in the folder but thats way after the Event.Complete has been triggered and more importantly  DataEvent.UPLOAD_COMPLETE_DATA doesnt get called.
    Everything seems to work fine as long as the file size is under 1 MB
    Did others too face similar problems and any ideas on how to fix it?
    Thanks in advance

    I don't believe there is, as the browse button renders out as an html input type file component, and this has no ability to get native file size from the client. The only way to do it is to check the file size server side, but that kind of defeats the purpose to some extent, as the file is required to be uploaded before the file size can be checked.
    There is no way to do this on the client short of using a third party client side component - ie. java, flash or some other active component that gets file system level access.
    Ben

  • FileReference Select and Cancel Event Not Working in leopard

    FileReference not working in leopard
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="
    http://www.adobe.com/2006/mxml"
    layout="absolute">
    <mx:Script>
    <![CDATA[
    import mx.controls.Alert;
    public function onClick():void{
    var fr:FileReference=new FileReference();
    //fr.addEventListener(
    fr.addEventListener(Event.OPEN,openHandler);
    fr.addEventListener(Event.COMPLETE,completeHandler);
    fr.addEventListener(Event.SELECT,selectHandler);
    fr.addEventListener(Event.CANCEL,cancelHandler);
    fr.addEventListener(DataEvent.UPLOAD_COMPLETE_DATA,uploadCompleteDataHandler);
    fr.addEventListener(HTTPStatusEvent.HTTP_STATUS,httpStatusHandler);
    fr.addEventListener(IOErrorEvent.IO_ERROR,ioErrorHandler);
    fr.addEventListener(ProgressEvent.PROGRESS,progressHandler);
    fr.addEventListener(SecurityErrorEvent.SECURITY_ERROR,securityErrorHandler);
    fr.browse([new FileFilter("images", "*.png;*.jpg;*.gif")]);
    private function cancelHandler(event:Event):void {
    trace("cancelHandler: " + event);
    private function completeHandler(event:Event):void {
    trace("completeHandler: " + event);
    private function
    uploadCompleteDataHandler(event:DataEvent):void {
    trace("uploadCompleteData: " + event);
    private function
    httpStatusHandler(event:HTTPStatusEvent):void {
    trace("httpStatusHandler: " + event);
    private function ioErrorHandler(event:IOErrorEvent):void {
    trace("ioErrorHandler: " + event);
    private function openHandler(event:Event):void {
    trace("openHandler: " + event);
    private function progressHandler(event:ProgressEvent):void {
    var file:FileReference = FileReference(event.target);
    trace("progressHandler name=" + file.name + " bytesLoaded="
    + event.bytesLoaded + " bytesTotal=" + event.bytesTotal);
    private function
    securityErrorHandler(event:SecurityErrorEvent):void {
    trace("securityErrorHandler: " + event);
    private function selectHandler(event:Event):void {
    Alert.show("XD");
    ]]>
    </mx:Script>
    <mx:Button x="205" y="198" label="Button"
    click="onClick()"/>
    </mx:Application>
    Adobe Flex Builder 3 Beta3
    Leopard 10.5.1
    both Safari and firefox doesn't work

    Flash version is 115 debug player

  • Can i delete ALL files in directory ?

    i create a upload test using FileReference & PHP.
    In this scenario user upload files to http server.
    Now how can i delete all files in /files/uploads folder in AS3
    AS3 Code:
    req = new URLRequest();
    req.url = ( stage.loaderInfo.parameters.f )? stage.loaderInfo.parameters.f : "http://www.website.com/test/upload.php";
    uploadFile = new FileReference();
    select_btn.addEventListener( MouseEvent.CLICK, browse );
    uploadFile.addEventListener( Event.COMPLETE, complete_func );
    uploadFile.addEventListener( DataEvent.UPLOAD_COMPLETE_DATA, show_message );
    function browse( e:MouseEvent )
              filefilters = [new FileFilter('Images',"*.jpg;*.png;*.gif")];
              uploadFile.browse( filefilters );
    function complete_func( e:Event )
              trace( 'complete !' );
    function show_message(e:DataEvent)
    if (e.data == 'ok')
              label_txt.text = 'The file has been uploaded.';
    else if ( e.data == 'error')
              label_txt.text = 'The file could not be uploaded.';
    PHP Code:
    <?php
    $uploads_dir = './files/uploads';
    if( $_FILES['Filedata']['error'] == 0 ){
              if( move_uploaded_file( $_FILES['Filedata']['tmp_name'], $uploads_dir.$_FILES['Filedata']['name'] ) ){
                        echo 'ok';
                        exit();
    echo 'error';
    exit();
    ?>

    You need call another PHP file
    <?php
       $directory = './files/uploads';
       getDirectoryList ($directory);  
       //This function find all the files in the directory
       function getDirectoryList ($directory)
         // create an array to hold directory list
         $results = array();
         // create a handler for the directory
         $handler = opendir($directory);
         // open directory and walk through the filenames
         while ($file = readdir($handler)) {
           // if file isn't this directory or its parent, add it to the results
           if ($file != "." && $file != "..") {
        //$results[] = $file;
         // Delete Files
        $filename = $file;
      unlink($filename); //this delete a file
         // tidy up: close the handler
         closedir($handler);
    ?>

  • Problem on loading DAT file when using 3G network modem

    Hello,
    I'm having some strange problem when I'm trying to load my game on the part where DAT file with Map Object is read, using 3G Network Modem. This issue started when I migrated my applet from one host to another. Everything loads well, until the user authentication. On user authenticatiom I'm recieving map name which I should load and show the user on it. I'm recieving the message where map name is mentioned, but after, when the process of loading map begins(when I need to read DAT file which is only 15KB) application blocks(browser and JVM also block).
    I thought it could be because of slow network communication, but it's not the reason, since I have tested(using Bandwidth limiter software) with 5 KBs/Second and it loads well and application is running well.
    Any clue why this can happen? If code is needed I'll post some pieces related to the process of map creation.
    URL or application: [ http://mimosa.dei.uc.pt/serhiy/demo/hoonline.html|http://mimosa.dei.uc.pt/serhiy/demo/hoonline.html]
    Accounts: test01/test01 ... test0n/test0n ... test05/test05 (n is number from 1 to 5)
    Thanks in advance!

    You have to upload it with FileReference.upload() to a PHP
    (or other server-side) script which saves it to a folder on the
    server. When the DataEvent.UPLOAD_COMPLETE_DATA event has been
    dispatched you can then use the FileReference.name to load from the
    file on the server just like any other image.

  • Difference between 2 UPLOAD events

    Hello!
    What is the difference between
    Event.COMPLETE and
    DataEvent.UPLOAD_COMPLETE_DATA.
    I am uploading a file and currently am handling both. Problem
    is I would like to know why and if both need handling.
    Thank you!

    Per the docs, "UPLOAD_COMPLETE_DATA" is:
    "Dispatched after data is received from the server after a
    successful upload. This event is not dispatched if data is not
    returned from the server."
    Use this event if your server is returning data from the file
    upload.

  • Problem in Loading a File on the MovieClip..

    I want to load an image on the MovieClip at run time..
    This should be done using file reference Class instance..
    By this user can brwose the file load whatever he wants..
    I had tried this but when user select the file in code we
    just have name of the file not whole path..
    So to load an image on movieClip we require the whole path..
    Any one knows how I can achive this...??
    Thanks...

    You have to upload it with FileReference.upload() to a PHP
    (or other server-side) script which saves it to a folder on the
    server. When the DataEvent.UPLOAD_COMPLETE_DATA event has been
    dispatched you can then use the FileReference.name to load from the
    file on the server just like any other image.

Maybe you are looking for