1. //if the the user is uploading file then process it
  2. if (len(form.uploadFile))
  3.     {
  4.         //create resize object
  5.         variables.imgObj = createObject("component", "dl_com.tmt_img");
  6.         
  7.         //remove current file, if present in the form
  8.         if (len(form.currentPhoto))
  9.             {
  10.                 //remove exisiting photo if present
  11.                 variables.functionFile.removeFile    (
  12.                                                     fileName = form.currentPhoto,
  13.                                                     filePath = application.event.fullFilePath
  14.                                                     );                
  15.             }
  16.         //upload new file
  17.         variables.newFile = variables.functionFile.uploadFile    (
  18.                                                                 destination = application.orgFilePath,
  19.                                                                 fileField = "form.uploadFile",
  20.                                                                 acceptType = 'image/gif,image/jpg,image/jpeg,image/pjpeg',
  21.                                                                 nameConflict = 'makeunique'
  22.                                                                 );
  23.         
  24.         //name the new file
  25.         variables.fileName = 'propertyEvent' & '_' & randRange(1000,2000) & Right(variables.newFile,4);
  26.         //resize image and copy image to permanent location
  27.         variables.imgObj.resize    (
  28.                              source = application.orgFilePath & variables.newFile,
  29.                              destination = application.event.fullFilePath & variables.fileName,
  30.                              newWidth = application.event.fullSize
  31.                              );
  32.     
  33.      //remove original photo
  34.         variables.functionFile.removeFile    (
  35.                                             fileName = variables.newFile,
  36.                                             filePath = application.orgFilePath
  37.                                             );    
  38.                              
  39.      //set the file name for the bean
  40.      variables.beanEvent.setEventPhoto(variables.fileName);
  41.     }