Download & Upload File - RESTful API with Laravel - 13

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
[Music] assalamualaikum in this lecture we will download and upload a file using API first we will start by downloading a file for this creator out.get I'm just assigning this route name for understanding let's suppose we have different files and user want to download the files make the controller for downloading the file and here we are creating this route fide country list and the controller name file controller and the method country list let's open the terminal and PHP artisan make controller file controller then PHP artisan serve then public function country list and here we don't have any image or excel file that we made available to download so let's first copy a file in our public folder this user - dot PNG we will make this file available to download so let's return response and the function download and our file is in public folder so public pad and the file is in public folder so we don't need to give any folder name here so just the file name user - dot PNG and the file name user image now let's check this in postman file config list route and we need to authenticate using using basic auth and here is our image and if you check the header we see that the file is attached and the name of the file is user image and the file type is PNG let's go to upload a file using API first we will start by making a route of post and I will keep this route name and the method name country safe let's create this method public function country save requests the first set the file name file name variable user image dot jpg and the path where we will restore the file so request file and the file name photo we will move this into the public folder so move public path let's move this file directly to our public folder so the file name now the photo URL URL and the file name then return response Jason and the URL of the image which is in photo URL and a success code now let's access this URL using post method and we need authorization and use form data first we will give the key photo and then select this text and change this text to a file then choose file choose an image file we need to authenticate to authorize it using basic auth and when we click the send button and here you can see that the image is uploaded thank you very much for watching please subscribe to the channel and like the video and if you have an equation then leave it in comments section see you in the next lecture take care bye bye
Info
Channel: Atif Naseem
Views: 42,475
Rating: undefined out of 5
Keywords: laravel, laravel file upload, laravel tutorial, laravel image upload, laravel download, laravel upload, laravel tutorials, file upload, laravel 5, php laravel, upload file laravel, upload, file upload in laravel, upload file in laravel, laravel upload file, laravel download and install, laravel documentation, how to upload a file using laravel api, how to download a file using laravel api, how to upload file using api, how to download file using api, laravel api upload file
Id: 6CJ73IImcAY
Channel Id: undefined
Length: 6min 8sec (368 seconds)
Published: Tue Feb 26 2019
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.