I use laravel 5.6
My method to upload image like this :
public function uploadImage($file) {
if($file) {
$fileName = str_random(40) . '.' . $file->guessClientExtension();
}
$destinationPath = storage_path() . DIRECTORY_SEPARATOR . 'app' . DIRECTORY_SEPARATOR . 'public' . DIRECTORY_SEPARATOR . 'product';
if(!File::exists($destinationPath)) {
File::makeDirectory($destinationPath, 0755, true);
}
$file->move($destinationPath, $fileName);
return $fileName;
}
The code works. If the method run, it will save a file in product folder
But I want to add a logic. If the image success save in product folder, then it will make a folder thumb in folder product
I try add this code below $file->move($destinationPath, $fileName);
like this :
$destinationPathThumb = storage_path() . DIRECTORY_SEPARATOR . 'app' . DIRECTORY_SEPARATOR . 'public' . DIRECTORY_SEPARATOR . 'product' . DIRECTORY_SEPARATOR . 'thumb';
if(!File::exists($destinationPathThumb)) {
File::makeDirectory($destinationPathThumb, 0755, true);
}
$file->move($destinationPathThumb, $fileName)
Then I rum my method, there exist error like this :
Parse error: syntax error, unexpected 'return' (T_RETURN)
It seems the code line is still wrong
How can I solve this problem?