Class file not found in laravel?

Following this tutorial on how to make uploads in laravel, encountered the following error Class 'AppModelsFile' not found
When typing php artisan serve in the terminal the server works fine but when you upload a file it throws the error mentioned above

I followed the steps carefully and checked File.php , FileUpload.php



namespace AppHttpControllers;

use IlluminateHttpRequest;
use AppModelsFile;

class FileUpload extends Controller
  public function createForm(){
    return view('file-upload');

  public function fileUpload(Request $req){
        'file' => 'required|mimes:csv,txt,xlx,xls,jpg,png,pdf|max:4096'

        $fileModel = new File;

        if($req->file()) {
            $fileName = time().'_'.$req->file->getClientOriginalName();
            $filePath = $req->file('file')->storeAs('uploads', $fileName, 'public');

            $fileModel->name = time().'_'.$req->file->getClientOriginalName();
            $fileModel->file_path = '/storage/' . $filePath;

            return back()
            ->with('success','File has been uploaded.')
            ->with('file', $fileName);





use IlluminateDatabaseMigrationsMigration;
use IlluminateDatabaseSchemaBlueprint;
use IlluminateSupportFacadesSchema;

class CreateFilesTable extends Migration
    public function up()
        Schema::create('files', function (Blueprint $table) {

    public function down()

I get the error at line 20 in app/Http/Controllers/FileUpload


Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

First, you create a model called File.

here the artisan code to create the model

php artisan make:model File -m

All methods was sourced from or, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Notify of

Inline Feedbacks
View all comments
Would love your thoughts, please comment.x