To update a record with a photo, I have used the unlink command to delete the photo in the corresponding directory. I have already saved the file name and path separately in the database and to delete the file, I have written it as follows:
unlink($task->FilePath.$task->TaskFile);
but return this error:
unlink(/assets/TaskFiles/2024/04/921308991.png): No such file or directory
Considering that my default address is the public branch on the server, how do I add the default address to be placed at the beginning of the address?
2
Answers
You’ll need to use the public_path function to get the full file path starting from the public directory
You can use the Storage facade to handle file operations. Here’s how you can delete a file using the Storage facade in Laravel