dcsimg
A Flash Developer Resource Site

Page 1 of 2 12 LastLast
Results 1 to 20 of 26

Thread: flash 8 file upload help returning data?

  1. #1
    AKA [ Paul Bainbridge] webdreamer's Avatar
    Join Date
    Aug 2001
    Location
    Glasgow, Scotland, UK
    Posts
    3,320

    flash 8 file upload help returning data?

    Right ok whats the deal with the flash 8 file upload facility?

    it's not possible to check for any returned data?
    -
    Taking from Macromedia help file live comments:
    abuchkin said on Sep 18, 2005 at 11:26 PM :
    Why there is no return value from the script page that file uploaded.
    It's not sense to trust the true value of this function to make sure yourself about to file has uploaded.
    What if your script is getting a file and saving it after inserting a database record and getting that ID to use as name and what if you need that ID from client side on flash.
    link

    Is this the case?

    thanks
    paul
    .: To me AS is like LEGO, Only for the big Kids :.
    - Site - Blog - Twitter - Linkedin
    bringmadeleinehome.com

  2. #2
    Mod cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,448
    The way I solved the problem is to load the uploaded file and display it in the flash movie. It's not the best solution but it works.
    - The right of the People to create Flash movies shall not be infringed. -
    | www.Flashscript.biz | Flashscript Biz Classes/Components |

  3. #3
    AKA [ Paul Bainbridge] webdreamer's Avatar
    Join Date
    Aug 2001
    Location
    Glasgow, Scotland, UK
    Posts
    3,320
    Eh? solved what? solution?
    The way I solved the problem is to load the uploaded file and display it in the flash movie
    Thats what it is supposed to do. hmmmm.......

    Example of what i am trying to acomplish.
    PHP Code:
    //error function
    function fail($errorMsg) {
        
    // URL-Encode error message
        
    $errorMsg urlencode($errorMsg); 
        
    // Output error information and exit
        
    print "&return_error=Fail&errormsg=$errorMsg";
        exit;
    }
    // Error is triggered when fail() is called anywhere
    // example use:
        
    $imageInfo getimagesize($_FILES['imgfile']['tmp_name']);
        
    $imagewidth $imageInfo[0];
        
    $imageheight $imageInfo[1];
    //Set allowed width and height    
        
    $maxwidth 300;
        
    $maxheight 225;
    //Check image does not exeed allowed width and hieght
        
    if(($imagewidth $maxwidth )or( $imageheight $maxheight)) {
        
    fail("Image exceeds dimensions 300*225");
        } 
    How do i return the fail var???
    .: To me AS is like LEGO, Only for the big Kids :.
    - Site - Blog - Twitter - Linkedin
    bringmadeleinehome.com

  4. #4
    Mod cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,448
    I am doing everything in flash, what you are trying to accomplish with php. Here is a url:

    http://flashscript.biz/components/fo...rchinform.html

    You need to enter a valid email and you get a url with login data, which leads you to a form, where you can upload pictures or text files. I do not want to publisize the url without that.
    If you upload a picture you know what I mean. Also try to upload a picture with the same url. There is also restriction regarding the size.

    From what I heard php will not return any value back to flash.
    - The right of the People to create Flash movies shall not be infringed. -
    | www.Flashscript.biz | Flashscript Biz Classes/Components |

  5. #5
    AKA [ Paul Bainbridge] webdreamer's Avatar
    Join Date
    Aug 2001
    Location
    Glasgow, Scotland, UK
    Posts
    3,320
    You still need php to upload file file. flash just makes it easier to get that open file window. well thats from what i see.
    .: To me AS is like LEGO, Only for the big Kids :.
    - Site - Blog - Twitter - Linkedin
    bringmadeleinehome.com

  6. #6
    Mod cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,448
    Sure you need php but the php won't return anything back to flash, so you need to build in the traps and confirmations in flash, which is perfectly ok.
    - The right of the People to create Flash movies shall not be infringed. -
    | www.Flashscript.biz | Flashscript Biz Classes/Components |

  7. #7
    AKA [ Paul Bainbridge] webdreamer's Avatar
    Join Date
    Aug 2001
    Location
    Glasgow, Scotland, UK
    Posts
    3,320
    Can you give any examples?

    i am looking to return errors like wring dimenssions, image size to big etc.
    .: To me AS is like LEGO, Only for the big Kids :.
    - Site - Blog - Twitter - Linkedin
    bringmadeleinehome.com

  8. #8
    Mod cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,448
    Here is an example for filesize from my file:

    PHP Code:
    uploadBtn.onRelease = function () {
                
    loaderBar._visible true;
                if (
    selectFile == "textfile") {
                    
    //
                    
    file.upload ("uploadText.php");
                    
    _level0.database.message.text "Selected: "+file.name;
                    if (!
    file.upload ("uploadText.php")) {
                        
    _level0.database.message.text "Upload dialog failed to open.";
                    }
                } else if (
    selectFile == "image" && file.size<=200000) {
                    
    file.upload ("uploadImage.php");
                    
    _level0.database.message.text "Selected: "+file.name;
                    if (!
    file.upload ("uploadImage.php")) {
                        
    _level0.database.message.text "Upload dialog failed to open.";
                    }
                } else if (
    file.size>200000) {
                    
    Alert.show ("Upload stopped. File is too large.""ERROR:"flagsparentclickHandler"alertIcon"defaultButton);
                }
            }; 
    - The right of the People to create Flash movies shall not be infringed. -
    | www.Flashscript.biz | Flashscript Biz Classes/Components |

  9. #9
    AKA [ Paul Bainbridge] webdreamer's Avatar
    Join Date
    Aug 2001
    Location
    Glasgow, Scotland, UK
    Posts
    3,320
    hmmm....
    Looks ok
    .: To me AS is like LEGO, Only for the big Kids :.
    - Site - Blog - Twitter - Linkedin
    bringmadeleinehome.com

  10. #10
    Mod cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,448
    if you need to check the image size(width, height) of the pic, preload it into an empty mc, check the width and height and then make it ready to upload or prevent upload. It can all be done in Flash.

    MM wants to make you php-independent They are not quite ready yet.
    - The right of the People to create Flash movies shall not be infringed. -
    | www.Flashscript.biz | Flashscript Biz Classes/Components |

  11. #11
    AKA [ Paul Bainbridge] webdreamer's Avatar
    Join Date
    Aug 2001
    Location
    Glasgow, Scotland, UK
    Posts
    3,320
    Ok next question.

    Preloader... how did you do it?

    Plus my file wont upload to the server for some reason That was whole point of the post in the first place("error checking")

    Thanks

    Advanced as my site is I am an AS2 newbie.
    .: To me AS is like LEGO, Only for the big Kids :.
    - Site - Blog - Twitter - Linkedin
    bringmadeleinehome.com

  12. #12
    Mod cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,448
    preloader:
    PHP Code:
    listener.onProgress = function (file:FileReferencebytesLoaded:NumberbytesTotal:Number):Void  {
            
    _level0.database.message.text "Loading in progress...";
            
    clipLoader.totalBox.text bytesTotal;
            
    clipLoader.loadBox.text bytesLoaded;
            var 
    frame:Number Math.ceil (bytesLoaded/(bytesTotal/100));
            
    loaderBar.gotoAndStop (frame);
        }; 
    it tells you a bit. But I am using my own preloader bar etc.

    Regarding the uploading: Is your file uploaded but does not show up?

    Chmod is not ok.

    Is your file not uploaded? You have a problem with your scripts or with your server.
    - The right of the People to create Flash movies shall not be infringed. -
    | www.Flashscript.biz | Flashscript Biz Classes/Components |

  13. #13
    AKA [ Paul Bainbridge] webdreamer's Avatar
    Join Date
    Aug 2001
    Location
    Glasgow, Scotland, UK
    Posts
    3,320
    folder permission are fine. i have other upload scripts working using diffrent methods to flash 8.
    .: To me AS is like LEGO, Only for the big Kids :.
    - Site - Blog - Twitter - Linkedin
    bringmadeleinehome.com

  14. #14
    Mod cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,448
    Here is one of the the upload scripts:
    PHP Code:
    <?php

    /************************************************************
     *     Setup variables
     ************************************************************/
    $site_name $_SERVER['HTTP_HOST'];
    $url_dir "http://".$_SERVER['HTTP_HOST'].dirname($_SERVER['PHP_SELF']);
    $url_this =  "http://".$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF'];

    $file_type $_FILES['userfile']['type']; 
    $file_name $_FILES['userfile']['name'];
    $file_ext strtolower(substr($file_name,strrpos($file_name,".")));
     
    //path to folder
    $folder'images';

    //path name of file for storage
    $uploadfile "$folder/" basename$_FILES['Filedata']['name'] );

    //if the file is moved successfully
    if ( move_uploaded_file$_FILES['Filedata']['tmp_name'] , $uploadfile ) ) {

        
    // change permissions for the file
        
    chmod"$folder/" basename$_FILES['Filedata']['name']),0644);
        if (!
    chmod"$folder/" basename$_FILES['Filedata']['name']),0644)) {
             
    fail("The permissions failed to set to 0644.");
        }
    }
    ?>
    - The right of the People to create Flash movies shall not be infringed. -
    | www.Flashscript.biz | Flashscript Biz Classes/Components |

  15. #15
    AKA [ Paul Bainbridge] webdreamer's Avatar
    Join Date
    Aug 2001
    Location
    Glasgow, Scotland, UK
    Posts
    3,320
    Will give it a try thanks
    .: To me AS is like LEGO, Only for the big Kids :.
    - Site - Blog - Twitter - Linkedin
    bringmadeleinehome.com

  16. #16
    AKA [ Paul Bainbridge] webdreamer's Avatar
    Join Date
    Aug 2001
    Location
    Glasgow, Scotland, UK
    Posts
    3,320
    Hi again.

    Can you tell me how the fail() is working?
    PHP Code:
       if (!chmod"$folder/" basename$_FILES['Filedata']['name']),0644)) { 
             
    fail("The permissions failed to set to 0644."); 
        } 
    Thanks
    Paul
    .: To me AS is like LEGO, Only for the big Kids :.
    - Site - Blog - Twitter - Linkedin
    bringmadeleinehome.com

  17. #17
    AKA [ Paul Bainbridge] webdreamer's Avatar
    Join Date
    Aug 2001
    Location
    Glasgow, Scotland, UK
    Posts
    3,320
    Right i am still getting no where.

    Folder permissonfor upload set to 777.
    php script- line:
    PHP Code:
    move_uploaded_file($_FILES['selectedFile']['tmp_name'], "../../img/vids/");    
    //Since no errors can be returned there is less need for code. 
    The listener to start the upload
    code:

    listener.onSelect = function (selectedFile:FileReference):Void {
    if (selectedFile.size > 200000) {
    statusArea.text = "Error file is to large. File should be no more than 200kb";
    } else {
    statusArea.text += "Attempting to upload " + selectedFile.name + "\n";
    // Upload the file to the PHP script on the server.
    selectedFile.upload (path2ADM+"vidThumbUp.php");
    }
    };


    All returns ok but the file dosn't seem to get uploaded.

    Anyone any ideas?

    Thanks
    Paul
    .: To me AS is like LEGO, Only for the big Kids :.
    - Site - Blog - Twitter - Linkedin
    bringmadeleinehome.com

  18. #18
    Mod cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,448
    The fail is not working. I tried once and did not take it out.

    I don't know your script how you do the upload. It is probably your flash file. I started with the flash help file script and moved on from there.
    - The right of the People to create Flash movies shall not be infringed. -
    | www.Flashscript.biz | Flashscript Biz Classes/Components |

  19. #19
    AKA [ Paul Bainbridge] webdreamer's Avatar
    Join Date
    Aug 2001
    Location
    Glasgow, Scotland, UK
    Posts
    3,320
    Same here m8. Stopped working as soon as i changed path2php to my server
    .: To me AS is like LEGO, Only for the big Kids :.
    - Site - Blog - Twitter - Linkedin
    bringmadeleinehome.com

  20. #20
    AKA [ Paul Bainbridge] webdreamer's Avatar
    Join Date
    Aug 2001
    Location
    Glasgow, Scotland, UK
    Posts
    3,320
    Do u know where this is coming from and how it is being triggered?
    code:

    if (event.total == -1) {
    statusArea.text = "An error ocurred!";
    }


    ?
    .: To me AS is like LEGO, Only for the big Kids :.
    - Site - Blog - Twitter - Linkedin
    bringmadeleinehome.com

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center