application.ptPhotoGallery.scripts.loadJQuery();
application.ptPhotoGallery.scripts.loadADFLightbox();
// set the form action variable
if ( NOT StructKeyExists(request.params, "formAction") )
request.params.formAction = "upload";
if ( NOT StructKeyExists(request.params, "uploadDoc") )
request.params.uploadDoc = "";
if ( NOT StructKeyExists(request.params, "category") )
request.params.category = "";
if ( NOT StructKeyExists(request.params, "fieldName") )
request.params.fieldName = "";
if ( NOT StructKeyExists(request.params, "formSource") )
request.params.formSource = "";
if ( NOT StructKeyExists(request.params, "imgReplace") )
request.params.imgReplace = 0;
// Set the default values
photoTempDirPath = "";
photoTempURLPath = "";
serverTempFile = "";
errorFlag = false;
errorMsg = "";
errorAppMsg = "";
#application.ptPhotoGallery.ui.lightboxHeader()#
// Read the original image
imageData = ImageRead(photoTempDirPath);
//application.ADF.utils.dodump(imageData, "imageData", false);
// Check if the file extension is not the Destination Doc Type
if ( LEN(application.ptPhotoGallery.appConfig.DEST_DOC_TYPE) AND fileExtension NEQ application.ptPhotoGallery.appConfig.DEST_DOC_TYPE ){
try{
// Replace the extension in the temp file name
serverTempFile = ReplaceNocase(serverTempFile,".#fileExtension#", ".#application.ptPhotoGallery.appConfig.DEST_DOC_TYPE#" );
// Create the new image paths
newPhotoTempDirPath = "#application.ptPhotoGallery.appConfig.upload_path#temp/#serverTempFile#";
newPhotoTempURLPath = "#application.ptPhotoGallery.appConfig.upload_URL#temp/#serverTempFile#";
// Convert the image to Destination Doc Type
ImageWrite(imageData, newPhotoTempDirPath);
// Delete the old image format
fileDeleteOp = application.ptPhotoGallery.csdata.CSFile(action="delete", file="#photoTempDirPath#");
// Store the new image paths back into the paths
photoTempDirPath = newPhotoTempDirPath;
photoTempURLPath = newPhotoTempURLPath;
// Reload the image data for processing
imageData = ImageRead(photoTempDirPath);
}
catch (any cfcatch){
errorFlag = true;
errorMsg = cfcatch.detail;
errorAppMsg = "Please contact the administrator to check the Photo Gallery configuration for the Destination File Type.";
}
}
errorFlag = true;
errorMsg = cfcatch.detail;
errorAppMsg = "Error uploading the file.";
An error occurred while trying to upload the photo.