Does your webserver user have write permission for the public/storage directory?
Any reason you are not using the Laravel FileSystem?
Hi, I am having a trouble with 'unlink' and it makes me crazy. I am uploading a video file (limited 1) and everything works fine. According to my system user can upload just 1 video. So if he/she upload second video, system overwrite new video to old video. But i always get error in my log file.
Version: 5.6.16
public function upload( \Illuminate\Http\Request $request, Emlak $emlak, $type = 'image') { if($request->hasFile('file')) { $file = $request->file('file'); if($type == 'image') { $emlakImage = $this->saveImage($emlak, $file); return [ 'emlak_image_id' => $emlakImage->id ];
} elseif($type == 'video') {
$md5Name = md5_file($request->file('file')->getRealPath() ) . time();
$guessExtension = $request->file('file')->guessExtension();
$emlakVideo = $file->storeAs('videos', $md5Name . '.mp4', 'public');
$oldVideo = $emlak->video_url;
$emlak->video_url = $emlakVideo;
if($emlak->save()) {
if(file_exists(public_path('/storage/') . $oldVideo));
unlink( public_path('/storage/') . $oldVideo);
}
return [
'emlak_video_url' => $emlakVideo
];
}
}
return false;
}
When i run the system (in my localhost windows 10 + xampp + php 7.1.20)
Log file error: unlink(C:\xampp71\htdocs\myproject\public\/storage/): Permission denied at C:\xampp71\htdocs\myproject\app\Http\Controllers\Admin\EmlakController.php:539)
Thank you.
Please or to participate in this conversation.