I made a script to crop my image files on upload, when insert or update and it’s work, I use a code like this:Here a snipt of my code to better unsertanding:
CustomResize($this->img, rv_ClearString($rsnew['img']), 1000, 300, "./images/tb/");
function CustomResize($cp_origFile, $new_files, $final_width_file, $final_height_file, $file_tbFolder)
{
$images = explode(",", $new_files);
//Define a pasta onde será gravada o Thumbnail
$thumbPath = $cp_origFile->UploadPath . $file_tbFolder;
//move_uploaded_file($cp_origFile->Upload->FileName, $thumbPath);
foreach($images as $new_file)
{
//Try to send to server,
$cp_origFile->Upload->SaveToFile($thumbPath, $new_file, TRUE); ------->That is here that not working
...
<RESIZE AND CROP THIS IMG >
but this image filename doesn't exist in server, and create a blank croped image
...
}
}
I made some tests and SaveToFile function doesn’t work, because the $this->Value in cUpload class is empty, when it should have the image to upload. Next goes some prints of variable when try to upload multiple images:
row_updt: test1.jpg,test2.jpg,test3.jpg,test4.jpg → in row_updating(), the $rsnew[‘img’] variablecustomResize() - new_file: test1.jpg → value sent after made the explode (sent to save each image)
$this->Value: null
path: C:\Program Files\EasyPHP\data\localweb\quintadalixa.pt\assets\images\conteudos
NewFileName: test1.jpg
this->FileName: test1.jpg,test2.jpg,test3.jpg,test4.jpgcustomResize - new_file: test2.jpg
$this->Value: null
path: C:\Program Files\EasyPHP\data\localweb\quintadalixa.pt\assets\images\conteudos
NewFileName: test2.jpg
this->FileName: test1.jpgcustomResize - new_file: test3.jpg
$this->Value: null
path: C:\Program Files\EasyPHP\data\localweb\quintadalixa.pt\assets\images\conteudos
NewFileName: test3.jpg
this->FileName: test2.jpgMy qestion is how to pre-upload files to server with SaveToFile() function or other, for crop image after.