I try to use Intervention for resize a photo added by the user in a form :
if(!empty($_POST))
{
$con = new \App\Controller\CreateController();
if($con->create(['name' => $_POST['title'], 'content' => $_POST['content'], 'users_id' => $_SESSION['auth']->id]))
{
$postid = App::getInstance()->getDB()->lastInsertId();
if($con->media(['media_name' => $_FILES['image']['name'], 'posts_id' => $postid]) && $con->thumbs($_FILES['image']['name']))
{
?>
<div class="alert-success">Post Created !</div>
<?php
header('refresh:2;url= ../public/admin.php?p=home');
}
}
}
The "create" function save the form information in my DB , the function "media" save the image to my DB and the "thumbs" function is supposed to resize and send the image to my thumbs directory using Intervention.
However, Intervention do not accept "$_FILES['image']['name']" parameter.
This is my function thumbs :
public function thumbs($image){
$manager = new ImageManager();
$manager->make('../public/'.$image)
->fit(400,250)
->save('../public/images/thumbs/' .pathinfo($image, PATHINFO_FILENAME) . '.jpg');
return true;
}
Someone can help me?