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

    Sending variables to file upload page

      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

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

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

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

      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

        • 1. Sending variables to file upload page
          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?