Tutorialsplane

Laravel delete file from folder


Laravel delete file from folder – The Laravel delete file from folder is used to delete file from the directory.


Laravel delete file from folder | with full Example.

Let us understand how to use Laravel delete file from the folder.

Full example of laravel delete file.

Now here i am going to explain how to delete file from directory.

First we have to create controller page and save as [DeleteController.php].

Let’s look at a simple example.

<?php namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Illuminate\Support\ServiceProvider;
use App\Http\Requests;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Input;
use File;

class DeleteController extends Controller 
{
public function dodelete()
{		
   if(file_exists('../images/abc.txt'))
    {
	unlink('../images/abc.txt');
    }
	return 'file is deleted';	   
}	
}

</pre?>

Route Part:-

Route::get('/delete','ImportController@dodelete');

Output will be same like this:-

Laravel Tutorial