• User

    Limite di peso del file in un upload di file in flash

    Ciao!
    Sto utilizzando questa semplice sorgente (as + php) che permette all'utente di caricare delle immagini dal sito in cui si trova.
    E' già presente una restrizione per quanto riguarda l'estensione dei file permessi, in più ho bisogno anche di una limitazione per quanto riguarda il peso del file.
    Di seguito il codice AS:

    
    //Allow this domain
    System.security.allowDomain("link del localhost");
    import flash.net.FileReference;
    // The listener object listens for FileReference events.
    var listener:Object = new Object();
    
    // When the user selects a file, the onSelect() method is called, and
    // passed a reference to the FileReference object.
    listener.onSelect = function(selectedFile:FileReference):Void {
      //clean statusArea and details area
      statusArea.text = details.text = ""
      // Flash is attempting to upload the image.
      statusArea.text += "Verifica del file..." + selectedFile.name + "\n";
      // Upload the file to the PHP script on the server.
      selectedFile.upload("upload.php");
    };
    
    // the file is starting to upload.
    listener.onOpen = function(selectedFile:FileReference):Void {
      statusArea.text += "Caricamento in corso..." + "\n";
    };
    //Possible file upload errors
    listener.onHTTPError = function(file:FileReference, httpError:Number):Void {
        imagePane.contentPath = "Errore";
        imagePane.content.errorMSG.text = "HTTPError number: "+httpError +"\nFile: "+ file.name;
    }
    
    listener.onIOError = function(file:FileReference):Void {
        imagePane.contentPath = "Errore";
        imagePane.content.errorMSG.text = "IOError: "+ file.name;
    }
    
    listener.onSecurityError = function(file:FileReference, errorString:String):Void {
        imagePane.contentPath = "Errore";
        imagePane.content.errorMSG.text = "SecurityError: "+SecurityError+"\nFile: "+ file.name;    
    }
    
    // the file has uploaded
    listener.onComplete = function(selectedFile:FileReference):Void {
      // Notify the user that Flash is starting to download the image.
      statusArea.text += "Caricamento terminato.\nInvio del file" + " come anteprima.\n";
      //Show file details
      details.text = ""
      for(i in selectedFile) details.text +="<b>"+i+":</b> "+selectedFile*+"\n"
      // Call the custom downloadImage() function.
      downloadImage(selectedFile.name);
    };
    
    var imageFile:FileReference = new FileReference();
    imageFile.addListener(listener);
    
    uploadBtn.onPress = uploadImage;
    imagePane.addEventListener("Completato.", imageDownloaded);
    
    // Call the uploadImage() function, opens a file browser dialog.
    function uploadImage(event:Object):Void {
      imageFile.browse([{description: "File di immagine", extension: "*.jpg;*.gif;*.png"}]);
    }
    
    // If the image does not download, the event object's total property
    // will equal -1. In that case, display am error message
    function imageDownloaded(event:Object):Void {
      if(event.total == -1) {
        imagePane.contentPath = "Errore";    
      }
    }
    
    // show uploaded image in scrollPane
    //modificato da Linkbruttocane percorso per Hosting Windows
    function downloadImage(file:Object):Void {
      imagePane.contentPath =  "files/" + file;
    }
    
    stop()
    
    ```Qualche idea...?
    Grazie!

  • User

    Help!!!!!!!!!!!