0 Replies Latest reply on Jan 25, 2007 3:36 PM by jlingwai

    Uploading File

    jlingwai
      Hey,
      I have a really simple flex app with all the code below. Its just a button that uploads a file. I don't get an error when I run it local however the file doesn't get upload. When I upload it a server and run it i get an ioError #2038. I'm almost possitive that I have the correct permisions for the folder on the server. Can anyone point me in the right direction.

      Flex code:
      <?xml version="1.0" encoding="utf-8"?>
      <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="initCmp()">
      <mx:Script>
      <![CDATA[
      import flash.net.FileReference;
      import mx.controls.Alert;
      public var fileRef:FileReference = new FileReference();
      public var uploadURL:URLRequest = new URLRequest();
      public var allTypes:Array = new Array();
      public function initCmp():void{
      uploadURL = new URLRequest();
      uploadURL.url = " http://www.myserver.com/uploader/upload.cfm";
      uploadURL.method = URLRequestMethod.POST;
      var imageTypes:FileFilter = new FileFilter("Images (*.jpg, *.jpeg, *.gif, *.png)", "*.jpg; *.jpeg; *.gif; *.png");
      var textTypes:FileFilter = new FileFilter("Text Files (*.txt, *.rtf)", "*.txt; *.rtf");
      allTypes = new Array(imageTypes);
      }
      public function uploadImg():void{
      fileRef = new FileReference();
      configureListeners(fileRef);
      fileRef.browse(allTypes);
      }
      private function configureListeners(dispatcher:IEventDispatcher):void {
      dispatcher.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler);
      dispatcher.addEventListener(Event.SELECT, selectHandler);
      }
      private function selectHandler(event:Event):void {
      fileRef.upload(uploadURL);
      }
      private function ioErrorHandler(event:IOErrorEvent):void {
      Alert.show("ioErrorHandler: " + event.toString());
      }
      ]]>
      </mx:Script>
      <mx:Button x="279" y="186" label="UPLOAD!!!!!!!!!!!!!!!!!!!!!!!!" click="uploadImg();"/>
      </mx:Application>


      CF file upload.cfm:
      <cffile
      action="upload"
      filefield="FILEDATA"
      destination="#GetDirectoryFromPath(GetCurrentTemplatePath())#upload\#FORM.FILENAME#"
      nameconflict="overwrite"
      >


      As you can see really basic and it still doesn't work. Am i just forgetting something

      Thanks
      Josh