5 Replies Latest reply on Dec 14, 2007 2:37 PM by Damon Edwards

    flash fileReference class

    chopTheWood Level 1
      I'm using the flash fileReference class to upload an image to the server. I want to be able to alter the file name of the selected file before it actually uploads. I've tried changing the var 'file.name' (below) but it has no effect whatever in the saved file name. I'd actually like to be able to stop the script after the users has browsed for the file before proceeding with the upload but I was able to do that either.
      thank you for your ideas
        • 1. Re: flash fileReference class
          Greg Dove Level 4
          I've not tried this, but if you can't change the name that your upload script receives, why don't you just try passing a $_GET variable with your upload request with the new name that you want?
          Something like...

          var newName = 'myNewJPG.jpg;

          listener.onSelect = function(file:FileReference):Void {
          fileName_txt.text = "Begin Uploading: "+file.name;
          if (!file.upload(phpPath+"?saveAsName="+newName)) {
          ...

          then retrieve the name that you want to save the file as from the $_GET array in the do_UploadArt.php php script :

          $SaveAs=$_GET['saveAsName'];





          • 2. Re: flash fileReference class
            chopTheWood Level 1
            I'm not sure about the ? in
            if (!file.upload(phpPath+"?saveAsName="+newName))

            But I know that I get an HTTP error if it's not there.

            Anyway, I tried what you suggested but nothing gets loaded now even though I don't get an error!
            this is in my php script:
            -------------
            $test=$_GET['saveAsName'];
            $FiledataName=$_FILES['Filedata']['name'];
            $FiledataName=$test.$FiledataName;
            ------------
            (I'm adding something onto the front of the filename)

            this is the actionscript:
            phpPath is previously defined as:"php/do_UploadArt.php";
            ----------------
            var listener:Object = new Object();
            listener.onSelect = function(file:FileReference):Void {
            var newName = "addToFileName";
            fileName_txt.text = "Begin Uploading: "+file.name;
            //"php/uploadmyPhoto.php"
            if (!file.upload(phpPath+"?saveAsName="+newName)) {
            results_txt.text = "Upload dialog failed to open.";
            }
            ----------------

            Hmmm...
            • 3. Re: flash fileReference class
              Greg Dove Level 4
              Do you have an http debugger? If not, do you have it visible publicly somewhere where I could attempt a test upload and take a look at the http data for you?
              • 4. Re: flash fileReference class
                Greg Dove Level 4
                BTW the "?" in the url is just the start of the querystring which defines the $_GET array in php.

                Its the same as what you see in the browser address bar up top ^

                • 5. flash fileReference class
                  Damon Edwards Level 3
                  sorry to intrude, but GWD, will you have a look here please? Link

                  by the way chopTheWood, this is regarding your post.