Laravel delete file in app folder (root)

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP



Laravel delete file in app folder (root)



How to delete files from Laravel app directory (not the public directory but the one in the root)?



I tried :


Storage::Delete('Appfile.php');
Storage::Delete('Appfile.php');
File::Delete('Appfile.php');
File::Delete('Appfile.php');
unlink ('Appfile.php');



Nothing works.



UPDATE:
The file is in something like Appfolderfolderfile.db


Appfolderfolderfile.db




1 Answer
1



When not specifying an absolute path then what is used is the current working directory (the value that getcwd() would return). Usually, that's the /public directory and not the actual project root.


getcwd()


/public



You need to specific an absolute path using the Laravel helpers:


File::delete(app_path('file.php'));



Note: You can't use the Storage helpers because they are limited to only work within the app storage folder.


Storage






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

Firebase Auth - with Email and Password - Check user already registered

Dynamically update html content plain JS

Creating a leaderboard in HTML/JS