I'm trying to save an image I get via form.
I'm using move_uploaded_file()
for this.
Currently, my code looks like this:
class Image
{
public function save($image)
{
$name = time();
$destination = "public/img/vehicles/" . $name . ".jpg";
$result = move_uploaded_file($image['tmp_name'], $destination);
return $result;
}
}
File that I get form data:
$image = $_FILE['image'];
$saveImage = new Image();
$destinationImg = $saveImage->save($image);
But when I check the directory, the image is not there.
And $resultImg
always returns false
.