Laravel Tutorials
- What is laravel
- Laravel Installation
- Directory Structure
- htaccess
- Remove public from url
- Artisan Command
- Laravel Configuration
- Routing Configuration
- Namespaces
- Request
- Response
- Controller
- Model
- User Authentication
- Multi User Authentication
- Database Seeding
- Database
- Database Query
- ORM
- One-to-One Relationship
- One-to-Many Relationship
- Many to Many Eloquent Relationship
- Has One Through
- Has Many Through
- Querying Relations
- Middleware
- Laravel Views
- Blade Views
- Print data on view page
- Get Site URL
- Get URL Segment
- Get images from Storage folder
- Clear cache
- Form Class not found
- Flash Message in laravel
- Redirections
- path
- CRUD Projerct
- CRUD in Laravel
- CRUD progran
- Laravel Validation
- Jquery Validation
- Cookie
- Session
- Email Send in laravel
- File uploading
- CSRF Protection
- Helper in Laravel
- Helper Functions
- Guzzle Http Client
- Paypal Payment Gatway Integration
- Cron Job in laravel
- Flash message
- path
- Errors Handling
- Date Format
- Date Format Validation
- Display Image on View Page
- Update User Status using toggle button
- Delete Multiple Records using Checkbox in Laravel?
- Confirmation Before Delete Record
- Delete image from storage
- Remove/Trim Empty & Whitespace From Input Requests
- Block IP Addresses from Accessing Website
- How to Disable New User Registration in Laravel
- Redirect HTTP To HTTPS Using Laravel Middleware
- CKEditor
- slug generate unique
- Prevent Browser's Back Button After Logout
- Datatable dunamically
- encrypt & Decript
- Download File
- Rest API
- Shopping Cart
- Shopping Cart Example
- Dynamic Category-Subcategory Menu
- Ajax Search
- Interview Question
- laravel Tutorilal link
- laravel Tutorilal
Important Links
How to delete image from storage in laravel?
public function delete_category(Request $request,$id='')
{
//DB::table('Categorys')->where('id',$id)->delete();
//$id = $request->get('id');
//$deletedRows = Category::where('id', $id)->delete();
//return redirect('showcategory');
$id = $request->get('id');
$data = Category::findOrFail($id);
$image_path = storage_path().'/category_image/'.$data->category_image;
unlink($image_path);
$data->delete();
// if(Storage::delete($data->category_image)) {
// $data->delete();
// }
return response()->json(['success'=>"Product Deleted successfully."]);
exit;
}
Using File System:
public function removeImage()
{
if(\File::exists(public_path('upload/itechxpert.png'))){
\File::delete(public_path('upload/itechxpert.png'));
}else{
dd('File does not exists.');
}
}
Using Storage System
File name : index.php
public function removeImage()
{
if(\Storage::exists('upload/itechxpert.png')){
\Storage::delete('upload/itechxpert.png');
}else{
dd('File does not exists.');
}
}
Using Core PHP:
public function removeImage()
{
if(file_exists(public_path('upload/itechxpert.png'))){
unlink(public_path('upload/itechxpert.png'));
}else{
dd('File does not exists.');
}
}
File name : index.php