Hello -
I'm trying to upload converted images into three separate locations, but so far - I've only managed to get the files into two locations.
My objective is:
SourceFile - to /uploads/
Thumbnail 1 - to /uploads/thumbz/
Thumbnail 2 - to /uploads/slides/
I have tried to set multiple pathways
I have tried SaveAs, to a third pathway
(didnt work for me)
Below I have pasted the converters I've setup & the uploaded file handlers below that
Could someone with experience
Please take a look
Maybe offer some sort of suggestion or course of action, or additional documentation
To achieve Three (3) separate locations for uploaded files
An example would be awesome
(i'm familiar with php, just not a 'programmer')
Thank you - for taking the time and attention to read this
Have a great day
Benn
The established converters are:
$converters = &$uploader->getConverters();
$converter = new Converter();
$converter->setMode("*.*=SourceFile");
$converters[] = $converter;
$converter = new Converter();
$converter->setMode("*.*=Thumbnail");
$converter->setThumbnailWidth(150);
$converter->setThumbnailHeight(150);
$converter->setThumbnailFitMode("Fit");
$converters[] = $converter;
$converter = new Converter();
$converter->setMode("*.*=Thumbnail");
$converter->setThumbnailWidth(650);
$converter->setThumbnailHeight(450);
$converter->setThumbnailFitMode("Fit");
$converters[] = $converter;
Entire Function:
function onFileUploaded($uploadedFile) {
global $galleryPath;
$absGalleryPath = "../tourphotos/".$_GET['tourId']."/";
$absThumbnailsPath = $absGalleryPath . 'thumbz' . DIRECTORY_SEPARATOR;
$absThumbnailsPathTwo = $absGalleryPath . 'slides' . DIRECTORY_SEPARATOR;
if ($uploadedFile->getPackage()->getPackageIndex() == 0 && $uploadedFile->getIndex() == 0) {
initGallery($absGalleryPath, $absThumbnailsPath, FALSE);
}
$originalFileName = $uploadedFile->getSourceName();
$sourceFileName = getSafeFileName($absGalleryPath, $originalFileName);
$convertedFiles = $uploadedFile->getConvertedFiles();
//Save original file.
//It is the first file in ConvertedFiles collection as we set first converter mode to SourceFile.
$sourceFile = $convertedFiles[0];
getSafeFileName($absGalleryPath, rawurlencode($uploadedFile->getSourceName()));
$sourceFile->moveTo($absGalleryPath . DIRECTORY_SEPARATOR . $sourceFileName);
//Save thumbnail.
//It is the second file in ConvertedFiles collection as we set second converter mode to Thumbnail.
$thumbnailFile = $convertedFiles[1];
$thumbnailFileName = getSafeFileName($absThumbnailsPath, rawurlencode($uploadedFile->getSourceName()));
$thumbnailFile->moveTo($absThumbnailsPath . DIRECTORY_SEPARATOR . $thumbnailFileName);
//Save thumbnail.
//It is the third file in ConvertedFiles collection as we set third converter mode to Thumbnail.
$thumbnailFile = $convertedFiles[2];
$thumbnailFileName = getSafeFileName($absThumbnailsPathTwo, rawurlencode($uploadedFile->getSourceName()));
$thumbnailFile->moveTo($absThumbnailsPathTwo . DIRECTORY_SEPARATOR . $thumbnailFileName);
//Load XML file which will keep information about files (image dimensions, description, etc).
//XML is used solely for brevity. In real-life application most likely you will use database instead.
$descriptions = new DOMDocument('1.0', 'utf-8');
$descriptions->load($absGalleryPath . 'files.xml');
//Save file info.
$xmlFile = $descriptions->createElement('image');
$xmlFile->setAttribute('name', $originalFileName);
$xmlFile->setAttribute('source', $thumbnailNames[0]);
$xmlFile->setAttribute('thumbnail1', $thumbnailNames[1]);
$xmlFile->setAttribute('thumbnail2', $thumbnailNames[2]);
$xmlFile->setAttribute('description', $uploadedFile->getDescription());
$descriptions->documentElement->appendChild($xmlFile);
$descriptions->save($absGalleryPath . 'files.xml');
}
Edited by user Tuesday, September 13, 2011 10:04:50 AM(UTC)
| Reason: Not specified