2 Replies Latest reply on May 21, 2007 11:15 AM by ekokurtz

    Sending variables to file upload page

    ekokurtz
      I'm working on an app where users can upload a logo for their company. I'm able to create a folder for their logo based on their company name ahead of the fileReference.browse() function, but is there a way to send the name of the newly created directory along with the filedata to the page that does the upload? I can't guarantee people will name their image something different from someone else, and while coldfusion will create a unique name if needed, flex doesn't know that happened so I would be potentially storing an incorrect filename unless I can save the image in the company's directory.

      Here is my code - very simple


      FLEX
      switch (accountChoice.selectedValue) {
      case "Club / Venue":
      var fileUpload:String = '/hr/imageupload/clubLogo.cfm';
      break;
      case "Band / Artist":
      var fileUpload:String = '/hr/imageupload/bandLogo.cfm';
      break;
      case "Partner / Advertiser":
      var fileUpload:String = '/hr/imageupload/adLogo.cfm';
      break;
      }

      fileName = fileRef.name;
      clubLogo.text = fileName;
      var uploadCFM:URLRequest = new URLRequest();
      uploadCFM.url = fileUpload;
      fileRef.upload(uploadCFM);

      COLDFUSION
      <cfoutput>
      <cffile action="upload" filefield="Filedata" destination="#ExpandPath('./clubs')#" nameconflict="makeunique"/>
      </cfoutput>


      I'd like to pass the variable in for the directory, and add it to the destination attribute above

      Any ideas/help would be greatly appreciated

      Ethan
        • 1. Sending variables to file upload page
          ractoon
          Not sure if I perfectly understand what you're trying to do, but if you wanted to send additional information with your upload I believe you can use URLVariables.

          For example, you'd create a URLVariable with the directory name you'd want to send along:

          var urlVar:URLVariables = new URLVariables;
          urlVar.companyDirectory = dir;

          then append it to your URLRequest

          var uploadCFM:URLRequest = new URLRequest("upload.cfm");
          uploadCFM.data = urlVar;

          from here it's just a matter of accessing the "companyDirectory" variable passed as $_POST or $_GET.
          • 2. Re: Sending variables to file upload page
            ekokurtz Level 1
            Yeah, I tried sending the name that way, but I couldn't get coldfusion to display any of the values (tried dumping both #url# and #form#) - what is the trick to access those variables after sending them from flex?