upload video in laravel 1

upload video in laravel

use Illuminate\Support\Facades\Request;


class UploadController extends Controller
{

    public function upload(Request $request)
    {

        if(Request::hasFile('file')){

            $file = Request::file('file');
            $filename = $file->getClientOriginalName();
            $path = public_path().'/uploads/';
            return $file->move($path, $filename);
        }

    }
}

Here is what the above code is Doing:
1. We are using the Request facade to check if the file is present in the request.
2. If the file is present, we are getting the file object using the file method.
3. We are getting the original name of the file using the getClientOriginalName method.
4. We are getting the path to the public folder using the public_path method.
5. We are moving the file to the public folder using the move method.

Similar Posts