use Illuminate\Http\Request; $request = Request::instance(); if($request->hasFile('avatar')) { //do something }
$request = Request::createFromGlobals(); if($request->hasFile('photo')) { $file = $request->file('photo'); $filename = $file->getClientOriginalName(); $path = $file->storeAs('photos', $filename); //store the file with original filename in a 'photos' folder }In this example, we create a new `Request` object from the global variables, then check if it has a file with the name "photo". If it does, we get the `UploadedFile` instance and extract the original filename. Then we use the `storeAs` method to store the file with the original filename in a folder named "photos". Overall, the `Illuminate\Http\Request` class and its `hasFile` method are very useful for handling file uploads in PHP applications built with Laravel.