When I create a product and upload images for it, I'm creating folder with product name. When I rename product, I need to rename folder with its images. I'm trying to do it with php function rename() but getting error:
rename(C:\OpenServer\domains\site.loc\public/green/images/case-phanteks-enthoo-luxe-tempered-glass-black/,C:\OpenServer\domains\kompik.loc\public/green/images/case222-phanteks-enthoo-luxe-tempered-glass-black/): �������� � �������. (code: 5)
Code:
$oldDir = public_path() . '/green' . '/images/' . str_slug($product->name) . '/';
$dir = public_path() . '/green' . '/images/' . str_slug($data['name']) . '/';
if($request->hasFile('photos')){ uploaded files
if (!File::isDirectory($dir)) {
File::makeDirectory($dir);
}
if($data['name']==$product->name) {
File::cleanDirectory($dir);
}
}
else //no files uploaded but name changed
{
if($data['name']!=$product->name){
rename($oldDir,$dir);
}
}
via Batmannn