Hello Guys, i am experiencing some issues with my file uploader component. I have used this over the years and it always worked perfectly. Its a file uploader in flex that uses a coldfusion component to upload files(pics) to a folder on the server and picks the name of the file after it has been uploaded into the folder so that in case it overwrites the name, my flex component gets the overwritten name.
Ever since i upgraded to coldfusion 11, i have had issues with it. The file is uploaded well but the name of the uploaded file doesn't show up in my flex textinput. Maybe coldfusion 11 changed a few things and can't figure it out. Please help me. Below is the flex component (picUploader.mxml) <?xml version="1.0" encoding="utf-8"?> <mx:FormItem xmlns:mx="http://www.adobe.com/2006/mxml" width="230" indicatorGap="0" creationComplete="init()"> <mx:Script> <![CDATA[ import mx.managers.PopUpManager; import mx.controls.Alert; import components.progress_popup; private var fileRef:FileReference; private var maxFileSize:Number=650; private var progress_win:progress_popup; private function init():void { fileRef=new FileReference(); fileRef.addEventListener(Event.SELECT, fileRef_select); fileRef.addEventListener(Event.OPEN, openHandler); fileRef.addEventListener(ProgressEvent.PROGRESS, progressHandler); fileRef.addEventListener(DataEvent.UPLOAD_COMPLETE_DATA, uploadDataComplete); fileRef.addEventListener(Event.COMPLETE, fileRef_complete); } private function browseAndUpload():void { var imageTypes:FileFilter=new FileFilter("Images (*.jpg, *.jpeg, *.gif, *.png)", "*.jpg; *.jpeg; *.gif; *.png"); fileRef.browse([imageTypes]); message.text=""; img.text=""; } private function fileRef_select(event:Event):void { var request:URLRequest=new URLRequest("coldfusion/picUpload.cfm") //Get the filesize var fileSize:Number=Math.round(fileRef.size / 1024); //If the current file size is less or equal to our max file size then up if (fileSize <= maxFileSize) { try { fileRef.upload(request); } catch (err:Error) { message.text="ERROR: zero-byte file"; } //image.text = event.currentTarget.name; createdprogressPopup(); } else { //If the file is to big, alert the user Alert.show("File is to large! Please select a file smaller than " + maxFileSize + "kb." + "Scale your image down to 400 * 300 pixels or 300 * 400 pixels.", 'oooch!', Alert.OK); } } private function fileRef_complete(event:Event):void { message.text+=" (complete)"; removeMe(); } private function createdprogressPopup():void { progress_win=progress_popup(PopUpManager.createPopUp(this, progress_popup, true)); } private function removeMe():void { PopUpManager.removePopUp(progress_win); } private function progressHandler(event:ProgressEvent):void { progress_win.uploadProgress.setProgress(event.bytesLoaded, event.bytesTotal); } private function openHandler(event:Event):void { progress_win.uploadProgress.label="Uploading %3%% of image file."; } public function uploadDataComplete(event:DataEvent):void { var result:XML=new XML(event.data); img.text+=result.message; /* status_txt.text += 'Upload Data Complete\n' status_txt.text += 'RESULT: ' + result.toString() + '\n' status_txt.text += 'STATUS: ' + result.status + '\n'; status_txt.text += 'MESSAGE: '+ result.message; */ } ]]> </mx:Script> <mx:HBox width="100%"> <mx:TextInput width="100%" id="img" editable="false" maxChars="50"/> <mx:Button label="Upload" click="browseAndUpload();"/> </mx:HBox> <mx:Label id="message"/> </mx:FormItem> Below is the Coldfusion Component (picUpload.cfm) <cfsetting RequestTimeout = "600"> <cfset mediapath = expandpath('../profilePics')> <!---<cftry>---> <cfprocessingdirective suppresswhitespace="true"> <cftry> <cffile action="upload" filefield="filedata" destination="#MediaPath#" nameconflict="makeunique" accept="image/jpeg,image/jpg,image/png,image/gif"/> <!--- Begin checking the file extension of uploaded files ---> <cfset acceptedFileExtensions = "jpg,jpeg,gif,png"/> <cfset filecheck = listFindNoCase(acceptedFileExtensions,File.ServerFileExt)/> <!--- read the image ----> <cfimage action="read" name="uploadedImage" source="#MediaPath#/#file.serverFile#" > <cfset ImageScaleToFit(uploadedImage,"",142,"bilinear")> <cfimage source="#uploadedImage#" action="write" destination="#MediaPath#/#file.serverFile#" overwrite="yes"> <cfimage action="read" name="myImage" source="#MediaPath#/#file.serverFile#" > <cfset ImageCrop(myImage,0,0,142,142)> <cfimage source="#myImage#" action="write" destination="#MediaPath#/#file.serverFile#" overwrite="yes"> <cfxml variable="status"><result><status>OK</status><message><cfoutput>#file.serverFile#</cfoutput></message></result></cfxml> <cfcatch> <cfxml variable="status"><result><status>Error</status><message><cfoutput>#cfcatch.Message#</cfoutput></message></result></cfxml> </cfcatch> </cftry> <cfoutput>#status#</cfoutput> </cfprocessingdirective> <!---</cftry>--->