//Default settings, you can override these in your extended cfc variables.acceptedExtensions = "png,pdf"; variables.maxSize = "1000";//In kB variables.destinationDir = expandPath(request.subsiteCache[1].url & '_cs_apps/uploads/'); variables.overwriteExistingFiles = false; //Thumbnails variables.generateThumbnails = true; variables.thumbnailMaxHeight = 100; variables.thumbnailMaxWidth = 100; //Validation functions, an array of function names that get called in order. //If any of them fails the entire upload fails. variables.validationFunctions = ArrayNew(1); ArrayAppend(variables.validationFunctions,"validateExtension"); ArrayAppend(variables.validationFunctions,"validateSize"); variables.thumbnailGenerators = ArrayNew(1); ArrayAppend(variables.thumbnailGenerators,"generateThumbnailForImage"); //Final fallthrough transparent image when nobody else above can handle it ArrayAppend(variables.thumbnailGenerators,"transparentImageGenerator"); var rtnStruct = StructNew(); var fileExtension = ''; rtnStruct.success = false; rtnStruct.msg = "Invalid extension. Valid extensions are: #variables.acceptedExtensions#"; if(ListFindNoCase(variables.acceptedExtensions,listLast(fileDetails.fileName,'.'))){ rtnSTruct.success = true; rtnStruct.msg = "Valid Extension"; } return rtnStruct; var rtnStruct = StructNew(); rtnStruct.success = false; rtnStruct.msg = "File too large. Maximum file size is #variables.maxSize#kb"; //kB, 1000 Bytes, 8 bits in a Byte. We are dealing with binary data. if(len(fileDetails.binary) lt variables.maxSize*8*100){ rtnStruct.success = true; rtnStruct.msg = "Valid Filesize"; } return rtnStruct; var rtnFileName = sourceFileName; var unique = false; var i = 0; var extension = ''; var rootFileName = ''; if( FileExists("#variables.destinationDir##sourceFileName#") ) { //The file exists, lets loop until we get a unique number. unique = false; i = 1; extension = listLast(sourceFileName,'.'); rootFileName = left(sourceFileName,(Len(sourceFileName)-Len(extension)-1)); while(!unique) { rtnFileName = "#rootFileName##i#.#extension#"; if(!FileExists("#variables.destinationDir##rootFileName##i#.#extension#")){ unique = true; } i = i+1; } } return rtnFileName; var rtnStruct = StructNew(); var thumbnailWidth = 0; var thumbnailHeight = 0; var resizeDimension = ''; rtnStruct.handledImage = false; rtnStruct.image = ""; resizeDimension = ""; //Figure out what we need to do to maintain the aspect ratio. if(imageInfo.width gt variables.thumbnailMaxWidth and imageInfo.height gt variables.thumbnailMaxHeight){ if(imageInfo.width gt imageInfo.height){ resizeDimension = "width"; }else{ resizeDimension = "height"; } }else if(imageInfo.width gt variables.thumbnailMaxWidth){ resizeDimension = "width"; }else if(imageInfo.height gt variables.thumbnailMaxHeight){ resizeDimension = "height"; } rtnStruct.handledImage = true; var rtnStruct = StructNew(); rtnStruct.image = ImageNew("",variables.thumbnailMaxWidth,variables.thumbnailMaxHeight,"argb"); rtnStruct.handledImage = true; return rtnStruct; var rtnStruct = StructNew(); rtnStruct.name = ""; rtnStruct.image = ""; if(len(currentValue)){ rtnStruct.name = currentValue; if(variables.generateThumbnails){ rtnStruct.image = _getThumbnail(currentValue); } } return rtnStruct; var returnStruct = StructNew(); var argumentCollection = StructNew(); var validationResults = ''; var fileDetails = StructNew(); var i = 0; fileDetails.fileName = arguments.fileName; fileDetails.temporaryPath = arguments.filePath; argumentCollection.fileDetails = fileDetails; returnStruct.success = true; returnStruct.message = "Validation Success"; return returnStruct; var source = arguments.filePath; var rtnStruct = StructNew(); var destination = ""; var createDirStatus = false; var logFileName = "fileUploadError.log"; if(!FileExists(source)) application.ADF.utils.doThrow(message="Source file does not exist.",type="custom",logerror=1,logfile=logFileName); if(!DirectoryExists(variables.destinationDir)) { // Create the directory createDirStatus = createUploadDir(); if ( !createDirStatus ) application.ADF.utils.doThrow(message="Destination directory does not exist.",type="custom",detail="Please create directory: #variables.destinationDir#",logerror=1,logfile=logFileName); } //Dont overwrite, so get a unique filename! if(!variables.overwriteExistingFiles) arguments.fileName = getUniqueFileName(arguments.fileName); destination = "#variables.destinationDir##arguments.fileName#"; // Moving the file using the ADF csFile application.ADF.csData.csFile(action="move",destination="#destination#",source="#source#"); application.ADF.utils.logAppend("File move success. From-- "&source&" To-- "&destination,"fileUpload.txt"); rtnStruct.success = true; rtnStruct.message = "File move success."; rtnStruct.fileName = arguments.fileName; return rtnStruct; var i = ""; var rtnHTML = ""; var argumentCollection = StructNew(); var img = ""; var thumbnailResults = ''; argumentCollection.filePath = "#variables.destinationDir##arguments.fileName#";