Import proper class.
//use Illuminate\Support\Facades\Request; // is not what you require instead use
use Illuminate\Http\Request;
Hello everybody,
I am trying to upload a file using $request->file('image') I have posted the code of the function and uses below, when I execute http://localhost:8000/mobile/create and then add my data and submit it goes to http://localhost:8000/mobile and I get this error FatalErrorException in MobileController.php line 48: Call to undefined method Illuminate\Support\Facades\Request::file()
How can I make the upload file functionality??? Any help?
use App\Http\Requests;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Request;
use App\Mobile;
//use Request;
class MobileController extends Controller {
public function store(Request $request)
{
$mobile = Request::all();
$Mob = Mobile::create($mobile);
$imageName = $Mob->id.'.'.$request->file('image')->getClientOriginalExtension();
$request->file('image')->move(base_path().'/public/images/devices/',$imageName);
return redirect('mobile');
}
}
public function store(Request $request)
{
$mobile = $request->all();
$Mob = Mobile::create($mobile);
$imageName = $Mob->id.'.'.$request->file('image')->getClientOriginalExtension();
$request->file('image')->move(base_path().'/public/images/devices/',$imageName);
return redirect('mobile');
}
Please or to participate in this conversation.