aondoe
59
12
Laravel

File upload not working

Posted 2 months ago by aondoe

Hello everyone.

I'm having trouble with file upload in laravel 5.6 I'm trying to upload images to my CMS I've created with Laravel.

I have a table called "post_its" below:

    public function up()
    {
        Schema::create('post_its', function (Blueprint $table) {
            $table->increments('id');
            $table->string('title');
            $table->text('content');
            $table->text('subject');
            $table->text('featured_img');
            $table->timestamps();
        });
    }

I had to add a column in the table to upload images so I did so like below:

    public function up()
    {
        Schema::table('post_its', function(Blueprint $table)
        {   
            //add a column to the post_its table and give it 100 characters. Also specify 100 characters
            $table->string('featured_img', 100)->nullable();
        });
    }

Here's my form data I'm trying to fix, as you can see below:

<form action="{{route('posts.update', $post->id)}}" method="POST" type="multipart/form-data">
<!--other form fields are here as well, but omitted for brevity-->
        <div class="form-group">
                <input type="file" name="featured_img" title="Featured image">
                
        </div>
</form>

Every other field works and updates the database table, but not this upload field. All the fields under the featured_img column says null. I was hoping after I added this column I could edit this column. Any suggestions?

Please sign in or create an account to participate in this conversation.

Laracasts Mascot

Hi, Have We Met Yet?

Did you know that, in addition to the forum, Laracasts includes well over 1000 lessons on modern web development? All for the price of one lunch out per month.

Sign Me Up

Channels

Reply to

Use Markdown with GitHub-flavored code blocks.