Level 10
I think your storage folder is not public
m working on ecommerce site, when i add product then it show on index page without image but image is saving in the destination folder, can anyone provide solution fot it,
code of ProductsController:
public function productPreview(Request $request)
{
$productsModel = new ProductsModel();
$product = $productsModel->getProduct($request->id);
if ($product == null) {
abort(404);
}
$gallery = array();
if ($product->folder != null) {
$dir = '../storage/app/public/moreImagesFolders/' . $product->folder . '/';
if (is_dir($dir)) {
if ($dh = opendir($dir)) {
$i = 0;
while (($file = readdir($dh)) !== false) {
if (is_file($dir . $file)) {
$gallery[] = asset('storage/moreImagesFolders/' . $product->folder . '/' . $file);
}
$i++;
}
closedir($dh);
}
}
}
return view('publics.preview', [
'product' => $product,
'cartProducts' => $this->products,
'head_title' => mb_strlen($product->name) > 70 ? str_limit($product->name, 70) : $product->name,
'head_description' => mb_strlen($product->description) > 160 ? str_limit($product->description, 160) : $product->description,
'gallery' => $gallery
]);
}
Please or to participate in this conversation.