// Resize the image
$outPut = array();
$returnVar = '';
exec('convert "'.$_FILES['item_file']['tmp_name'].'" -resize "x238" "'.$_FILES['item_file']['tmp_name'].'"',$outPut,$returnVar);
if($returnVar == 1)
{
$valErrors[] = 'There was an error resizing the image.';
}
function handleUpload($id,$col,$filesArr,$valErrors)
{
if(count($valErrors) == 0)
{
// Delete image file if the nurse already had one
$query = "select image_file from nurses where nurse_id = '".$this->Editor->escapeData($id)."'";
$result = $this->Editor->doQuery($query);
if($row = mysql_fetch_assoc($result))
{
unlink($this->dataDir.$row['image_file']);
}
// Copy file to data directory and update database with the file name.
if(move_uploaded_file($filesArr['tmp_name'],$this->dataDir.$filesArr['name']))
{
$query = "update nurses set image_file = '".$this->Editor->escapeData($filesArr['name'])."' where nurse_id = '".$this->Editor->escapeData($id)."'";
$result = $this->Editor->doQuery($query);
if(!$result)
{
$valErrors[] = 'There was an error updating the database.';
unlink($this->dataDir.$filesArr['name']);
}
}
else
{
$valErrors[] = 'The file could not be moved' . $filesArr['tmp_name'] . ' Name ' .$this->dataDir.$filesArr['name'] ;
break;
}
//
// Resize the image
//
if (!$image = new Imagick($this->dataDir.$filesArr['name'])) {
$valErrors[] = 'Unable to start Imagick';
return $valErrors;
}
if (!$image->scaleImage(200, 0)) {
$valErrors[] = 'Unable to scale image with Imagick';
return $valErrors;
}
if (!$image->writeImage($this->dataDir.$filesArr['name'])){
$valErrors[] = 'Unable to write scaled image with Imagick';
return $valErrors;
}
}
return $valErrors;
}
Users browsing this forum: No registered users and 12 guests