Smart Image Processor PHP 2 Support Product Page

Answered

Input masks for subfolders

Asked 02 Sep 2013 14:59:10
1
has this question
02 Sep 2013 14:59:10 David Woolley posted:
According to this FAQ:
www.dmxzone.com/go/16935/editing-the-input-mask-for-resizing-with-sip2-php/

QuoteIf you want to have the images placed in a subfolder of the upload path, use this kind of mask:
##path##/subfolder/##name##_thumb.jpg


I'm uploading to a variable folder:
$ppu->path = "images/case_images/".$testpath;

then 3 instances of SIPP2 with the following masks:

$sipporiginal->setMask("##path####name##_orig.jpg";
$sipplarge->setMask("##path##/large/##name##_large.jpg";
$sippthumbs->setMask("##path##/thumbs/##name##_thumb.jpg";

The first $sipporiginal creates the image, but the other 2 images are not created, and no subfolders created.

Error message:
"Warning: imagejpeg(images/case_images/wcdgw02092013\/large/P1040132_large.JPG): failed to open stream: No such file or directory in C:\xampp\htdocs\ForensicsDB\ScriptLibrary\lib\cImageEditor\cGD2ImageEditor.php on line 1158"

I see there's an extra backslash in this error message before the /large/

However if I leave out the subfolder part in the masks: /large/ or /thumbs/
then everything works. The 3 different sized images are created in the same variable folder.

Any suggestions?

BTW I have several posts in the last month that have not been responded to.



Replies

Replied 03 Sep 2013 14:06:20
03 Sep 2013 14:06:20 Teodor Kuduschiev replied:
Hello David,

In order to save the image into a folder, SIP PHP needs that folder to be created already.
Replied 03 Sep 2013 14:48:30
03 Sep 2013 14:48:30 David Woolley replied:
Thanks Teodor - I thought it would automatically create the folder.
Back to the drawing board!
Cheers
Dave
Replied 04 Sep 2013 15:03:50
04 Sep 2013 15:03:50 David Woolley replied:
I managed to solve this like so:


<?php
if(!file_exists("images/case_images/".$testpath."/thumbs")) 
{ 
mkdir("images/case_images/".$testpath."/thumbs",true);
}
if(!file_exists("images/case_images/".$testpath."/large"))
{
mkdir("images/case_images/".$testpath."/large",true);
}
?>


($testpath is the variable folder)
then the SIPP setmasks worked:

$sipporiginal->setMask("##path####name##_orig.jpg";
.
$sipplarge->setMask("##path##/large/##name##_large.jpg";
.
$sippthumbs->setMask("##path##/thumbs/##name##_thumb.jpg";

Replied 04 Sep 2013 15:26:24
04 Sep 2013 15:26:24 Teodor Kuduschiev replied:
Thank you for sharing your workaround with us!
Replied 10 Oct 2013 15:03:48
10 Oct 2013 15:03:48 David Woolley replied:
Thought I'd just mention that the MKDIR code block should go in between the PPU & SIPP Server Behavior code blocks, otherwise the subfolders won't be created. Initially I had the MKDIR code block before the PPU code.

I have an Ajax form that allows repeat uploads on the page, and found that the first image uploaded was not being processed after upload, because the subfolders (thumbs & large) were only created before the second image was uploaded.

I moved the MKDIR code below the PPU code and now it all works. Lots of head scratching!

Cheers
Dave
Replied 31 May 2014 05:22:40
31 May 2014 05:22:40 Greta Garberini replied:
this should really be included in the extension. It will happen all the time that a new subfolder needs to be created. lets say you want to put files in a "month folder" of a specific year.

Reply to this topic