Welcome Guest! You need to login or register to make posts.

Notification

Icon
Error

Options
Go to last post Go to first unread
promedia  
#1 Posted : Tuesday, September 13, 2011 6:31:04 AM(UTC)
promedia

Rank: Newbie

Groups: Member
Joined: 9/13/2011(UTC)
Posts: 4

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

Dmitry.Obukhov  
#2 Posted : Tuesday, September 13, 2011 9:20:53 PM(UTC)
Dmitry.Obukhov

Rank: Advanced Member

Groups:
Joined: 5/29/2010(UTC)
Posts: 1,310

Thanks: 8 times
Was thanked: 111 time(s) in 111 post(s)
Hello Benn,

You experience this problem because set the same names for the both converters on the server side:
Code:

…
//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);
…

Please use different names ($thumbnailFile and $thumbnailFile2):
Code:

//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.
$thumbnailFile2 = $convertedFiles[2];
$thumbnailFileName2 = getSafeFileName($absThumbnailsPathTwo, rawurlencode($uploadedFile->getSourceName()));
$thumbnailFile2->moveTo($absThumbnailsPathTwo . DIRECTORY_SEPARATOR . $thumbnailFileName);

Best regards,
Dmitry Obukhov
Technical Support. Aurigma, Inc.
promedia  
#3 Posted : Tuesday, September 13, 2011 9:45:06 PM(UTC)
promedia

Rank: Newbie

Groups: Member
Joined: 9/13/2011(UTC)
Posts: 4

I see what you are pointing out
Thank you for showing me, my mistake
I do appreciate your time and attention

Thank you
Benn
Dmitry.Obukhov  
#4 Posted : Tuesday, September 13, 2011 10:23:39 PM(UTC)
Dmitry.Obukhov

Rank: Advanced Member

Groups:
Joined: 5/29/2010(UTC)
Posts: 1,310

Thanks: 8 times
Was thanked: 111 time(s) in 111 post(s)
Thanks for your comment, Benn. If you have any additional questions or problems, please feel free to let me know.
Best regards,
Dmitry Obukhov
Technical Support. Aurigma, Inc.
Users browsing this topic
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.