[flexcoders] Re: how to get the name of a video file after upload

2010-01-04 Thread ZIONIST
How do i get it back into flex on the complete event?

--- In flexcoders@yahoogroups.com, claudiu ursica the_bran...@... wrote:

 I never worked with cold fusion ... however your code on the server writes 
 somewhere the file on the disk and names it somehow. The method that does 
 that could return the file name in case of a successful save and you can get 
 it back into flex on the complete event.
 
 HTH,
 Claudiu
 
 
 
 
 
 From: ZIONIST stinas...@...
 To: flexcoders@yahoogroups.com
 Sent: Mon, January 4, 2010 3:10:33 PM
 Subject: [flexcoders] how to get the name of a video file after upload
 

 hi guys, i have built a video uploader in flex with a coldfusion backend. 
 what i do is allow the user to upload a video file (using cffile) and use 
 ffmpeg to convert the file into .flv format(this is because flex videoplayer 
 only plays .flv files) which is then stored(file. flv) on the server. this 
 all works perfectly, but i want to get the name of the flv file on the server 
 into the textinput and store it in the database. how do i do that? here is 
 the code, in this case the textinput is filled with the original file 
 name(something like file.mov or file.mp4 etc and i want to fill it with the 
 name of the converted file eg file.flv)
 
 ?xml version=1.0 encoding=utf- 8?
 mx:FormItem xmlns:mx=http://www.adobe. com/2006/ mxml creationComplete= 
 init()
 
 mx:Script
 ![CDATA[
 import mx.managers. PopUpManager;
 import components.progress _popup;
 
 //video upload  / / / / 
 / / / ///
 private const FILE_UPLOAD_ URL:String = cfcs/vidUpload. cfm;
 private var fileRef:FileReferen ce;
 private var progress_win: progress_ popup;
 
 
 private function init():void
 {
 fileRef = new FileReference( );
 fileRef.addEventLis tener(Event. SELECT, fileRef_select) ;
 fileRef.addEventLis tener(Event. OPEN, openHandler) ;
 fileRef.addEventLis tener(ProgressEv ent.PROGRESS, progressHandler) ; 
 fileRef.addEventLis tener(Event. COMPLETE, fileRef_complete) ;
 }
 
 private function browseAndUpload( ):void
 {
 //var fileFilter:FileFilt er = new FileFilter( Files, *.pdf;*.doc; 
 *.docx);
 fileRef.browse( );
 message.text = ;
 }
 
 private function fileRef_select( event:Event) :void 
 {
 try 
 {
 fileRef.upload( new URLRequest(FILE_ UPLOAD_URL) );
 } 
 catch (err:Error)
 {
 message.text = ERROR: zero-byte file;
 } 
 vid.text = event.currentTarget .name;
 createdprogressPopu p();
 } 
 
 private function fileRef_complete( event:Event) :void
 {
 message.text +=  (complete);
 removeMe();
 }
 
 private function createdprogressPopu p():void{
 progress_win= progress_ popup(PopUpManag er.createPopUp( this,progress_ 
 popup,true) );
 }
 
 private function removeMe():void {
 PopUpManager. removePopUp( progress_ win);
 }
 
 private function progressHandler( event:ProgressEv ent):void{
 progress_win. uploadProgress. setProgress( event.bytesLoade d, 
 event.bytesTotal) ; 
 }
 
 private function openHandler( event:Event) :void {
 progress_win. uploadProgress. label = Uploading %3%% of image file.;
 }
 ]]
 /mx:Script
 
 mx:HBox width=240
 mx:TextInput width=155 id=vid/
 mx:Button label=Browse click=browseAndUpl oad();/ 
 /mx:HBox
 mx:Label id=message /
 /mx:FormItem





Re: [flexcoders] Re: how to get the name of a video file after upload

2010-01-04 Thread Clint Tredway
What you need to do is create some xml in your file upload cfm page
cfprocessingdirective  suppresswhitespace=true
cftry
cffile action=upload result=newimg fileField=filedata
destination=#expandPath('/yourPath')# nameconflict=overwrite
cfxml
variable=statusresultstatusOK/statusmessagecfoutput#expandPath('/yourPath')#/cfoutput//message/result/cfxml
cfcatch
cfxml
variable=statusresultstatusError/statusmessagecfoutput#cfcatch.Message#/cfoutput/message/result/cfxml
/cfcatch
/cftry
cfoutput#status#/cfoutput
/cfprocessingdirective

, and then in your flex code you need to listen for the
DataEvent.UPLOAD_COMPLETE_DATA event and then you can parse that xml for the
file name.

public function uploadDataComplete(event:DataEvent):void
{
var result:XML = new XML(event.data);
/* status_txt.text += 'Upload Data Complete';
status_txt.text += 'RESULT: ' + result.toString()  + ''
status_txt.text += 'STATUS: ' + result.status + '\n';
status_txt.text += 'MESSAGE: '+ result.message + '\n';
status_txt.text += result.message + fileName; */
//newimg.source = ../../images/ + fileName;
}

HTH

On Mon, Jan 4, 2010 at 7:56 AM, ZIONIST stinas...@yahoo.com wrote:



 How do i get it back into flex on the complete event?


 --- In flexcoders@yahoogroups.com flexcoders%40yahoogroups.com, claudiu
 ursica the_bran...@... wrote:
 
  I never worked with cold fusion ... however your code on the server
 writes somewhere the file on the disk and names it somehow. The method that
 does that could return the file name in case of a successful save and you
 can get it back into flex on the complete event.
 
  HTH,
  Claudiu
 
 
 
 
  
  From: ZIONIST stinas...@...

  To: flexcoders@yahoogroups.com flexcoders%40yahoogroups.com
  Sent: Mon, January 4, 2010 3:10:33 PM
  Subject: [flexcoders] how to get the name of a video file after upload
 
 
  hi guys, i have built a video uploader in flex with a coldfusion backend.
 what i do is allow the user to upload a video file (using cffile) and use
 ffmpeg to convert the file into .flv format(this is because flex videoplayer
 only plays .flv files) which is then stored(file. flv) on the server. this
 all works perfectly, but i want to get the name of the flv file on the
 server into the textinput and store it in the database. how do i do that?
 here is the code, in this case the textinput is filled with the original
 file name(something like file.mov or file.mp4 etc and i want to fill it with
 the name of the converted file eg file.flv)
 
  ?xml version=1.0 encoding=utf- 8?
  mx:FormItem xmlns:mx=http://www.adobe. com/2006/ mxml
 creationComplete= init()
 
  mx:Script
  ![CDATA[
  import mx.managers. PopUpManager;
  import components.progress _popup;
 
  //video upload  / / /
 / / / / ///
  private const FILE_UPLOAD_ URL:String = cfcs/vidUpload. cfm;
  private var fileRef:FileReferen ce;
  private var progress_win: progress_ popup;
 
 
  private function init():void
  {
  fileRef = new FileReference( );
  fileRef.addEventLis tener(Event. SELECT, fileRef_select) ;
  fileRef.addEventLis tener(Event. OPEN, openHandler) ;
  fileRef.addEventLis tener(ProgressEv ent.PROGRESS, progressHandler) ;
  fileRef.addEventLis tener(Event. COMPLETE, fileRef_complete) ;
  }
 
  private function browseAndUpload( ):void
  {
  //var fileFilter:FileFilt er = new FileFilter( Files, *.pdf;*.doc;
 *.docx);
  fileRef.browse( );
  message.text = ;
  }
 
  private function fileRef_select( event:Event) :void
  {
  try
  {
  fileRef.upload( new URLRequest(FILE_ UPLOAD_URL) );
  }
  catch (err:Error)
  {
  message.text = ERROR: zero-byte file;
  }
  vid.text = event.currentTarget .name;
  createdprogressPopu p();
  }
 
  private function fileRef_complete( event:Event) :void
  {
  message.text +=  (complete);
  removeMe();
  }
 
  private function createdprogressPopu p():void{
  progress_win= progress_ popup(PopUpManag er.createPopUp( this,progress_
 popup,true) );
  }
 
  private function removeMe():void {
  PopUpManager. removePopUp( progress_ win);
  }
 
  private function progressHandler( event:ProgressEv ent):void{
  progress_win. uploadProgress. setProgress( event.bytesLoade d,
 event.bytesTotal) ;
  }
 
  private function openHandler( event:Event) :void {
  progress_win. uploadProgress. label = Uploading %3%% of image file.;
  }
  ]]
  /mx:Script
 
  mx:HBox width=240
  mx:TextInput width=155 id=vid/
  mx:Button label=Browse click=browseAndUpl oad();/
  /mx:HBox
  mx:Label id=message /
  /mx:FormItem
 

  




-- 
“When you choose hope, anything is possible.”
-Christopher Reeve


[flexcoders] Re: how to get the name of a video file after upload

2010-01-04 Thread ZIONIST
am sorry, am even more confused. is there a way to do this with the 
fileReference in flex?



Re: [flexcoders] Re: how to get the name of a video file after upload

2010-01-04 Thread Clint Tredway
yes, you are using fileReference.

public function selectFile():void
{
file = new FileReference();
file.addEventListener(Event.SELECT, fileSelected);
file.addEventListener(DataEvent.UPLOAD_COMPLETE_DATA, uploadDataComplete);
file.addEventListener(Event.COMPLETE, uploadComplete);
file.addEventListener(IOErrorEvent.IO_ERROR, handleError);
file.browse();
}
 public function handleError(event:IOErrorEvent):void
{
//status_txt.text = 'ERROR: ' + event.text + '';
trace(UPLOAD ERROR:  + event.text);
}
public function fileSelected(event:Event):void
{
file = FileReference(event.target);
//file_txt.text = file.name;
//status_txt.text = 'upload file: '+ file.name  + '';
fileName=file.name;
 var request:URLRequest = new URLRequest();
 request.url = /cfc/upload.cfm;
file.upload(request);
}
 public function uploadDataComplete(event:DataEvent):void
{
var result:XML = new XML(event.data);
/* status_txt.text += 'Upload Data Complete';
status_txt.text += 'RESULT: ' + result.toString()  + ''
status_txt.text += 'STATUS: ' + result.status + '\n';
status_txt.text += 'MESSAGE: '+ result.message + '\n';
status_txt.text += result.message + fileName; */
//newimg.source = ../../images/ + fileName;
}

On Mon, Jan 4, 2010 at 8:17 AM, ZIONIST stinas...@yahoo.com wrote:



 am sorry, am even more confused. is there a way to do this with the
 fileReference in flex?

  




-- 
“When you choose hope, anything is possible.”
-Christopher Reeve


Re: [flexcoders] Re: how to get the name of a video file after upload

2010-01-04 Thread claudiu ursica

in flex you register an event for DataEvent.UPLOAD_COMPLETE_DATA ...

fileReference.addEventListener(DataEvent.UPLOAD_COMPLETE_DATA, responseHandler);

private function responseHandler( event:DataEvent ) :void
{

here you should have in the event.data whatever you want to send back from cold 
fusion

Alert.show(response.toString())
}

TH
C



From: ZIONIST stinas...@yahoo.com
To: flexcoders@yahoogroups.com
Sent: Mon, January 4, 2010 4:17:31 PM
Subject: [flexcoders] Re: how to get the name of a video file after upload

   
am sorry, am even more confused. is there a way to do this with the 
fileReference in flex?