I use Laravel 5.3
When I upload image, I save the image in :
C:\xampp\htdocs\myshop\storage\temp
My code to save the image like this :
private function addPhoto(UploadedFile $photo, $fileName)
{
$destinationPath = storage_path() . DIRECTORY_SEPARATOR . 'temp';
$photo->move($destinationPath, $fileName);
return $fileName;
}
When I click button submit, I want to move the image from folder storage to folder public
So I want to move the image in :
C:\xampp\htdocs\myshop\public\img
How can I move the image in folder public?
Take a look at the rename
function.
Try something like that:
$org_image="C:\xampp\htdocs\myshop\storage\temp\xxxx.jpg";
$destination="C:\xampp\htdocs\myshop\public\img";
$img_name=basename($org_image);
if( rename( $org_image , $destination.'/'.$img_name )){
echo 'moved!';
} else {
echo 'failed';
}