My uploading function:
public function uploadImage($file, $path) {
$filename = Str::random(6) . '_' . time() . '_' . $file->getClientOriginalName();
$uploads_folder = public_path() . $path;
if (!file_exists($uploads_folder)) {
mkdir($uploads_folder, 0777, true);
}
$image = $path . "/" . $filename;
$file->move($uploads_folder, $filename);
return $image;
}
It worked fine for the past weeks but now this exception appeared:: Unsupported operand types
the return statement didn't apply but the file is saved on the folder correctly.
Maybe it's an issue with the
$pathvariable that you're using to construct the image and the unsupported operand types is probably because the $path is not outputting a String.To make sure that it is really a string you can use the
strvalaround the path like so: