无法存储图像总是说无法写入图像数据错误:无法将图像数据写入路径(E:\work\iShop-Admin-backend\storage/app/public/images/p/4069/11016/ 4069_11016_600x600.jpg) 我的代码:
$destinationPath = storage_path() . '/app/public/images/p/' . $product->id_product . '/';
if (!File::exists($destinationPath)) {
File::makeDirectory($destinationPath);
}
for ($i = 1; $i<=6; $i++){
if($row["image_{$i}"] != "")
$value = $row["image_{$i}"];
$contents = file_get_contents($value);
$imageBase64 = base64_encode($contents);
$filetype = \File::extension($value);
//$ext = ltrim($filetype, 'image/');
$ext = 'image/' . $filetype;
$media = 'data:' . $ext . ';base64,' . $imageBase64;
//Log::info($media);
//Log::info($ext);
if (!empty($media)) {
$position = ProductImage::where('id_product', $product->id_product)->max('position');
$data = array(
'id_product' => $product->id_product,
'position' => $position ? $position + 1 : 1,
'extension' => '.' . $filetype
);
if ($i == 1) {
$data['cover'] = 1;
} else {
$data['cover'] = 0;
}
$image = ProductImage::create($data);
LogController::log('STORE', 'catalog/product/upload/' . $product->id_product, $product->id_product, 'PRODUCT', 'add image to product where id_product=' . $product->id_product, null, $image);
if (!File::exists($destinationPath . $image->id_image)) {
File::makeDirectory($destinationPath . $image->id_image);
$destinationPath = $destinationPath . $image->id_image . '/';
$height = Image::make($media)->height();
$width = Image::make($media)->width();
}
}
}
如何解决?
繁华开满天机