Uploading Movie Cover Images in our Create or Edit Form

In this lesson, we'll learn how to upload movie cover images when either creating or editing a movie via our create or edit form.

Published
Jun 20, 24
Duration
10m 29s

Developer, dog lover, and burrito eater. Currently teaching AdonisJS, a fully featured NodeJS framework, and running Adocasts where I post new lessons weekly. Professionally, I work with JavaScript, .Net C#, and SQL Server.

Adocasts

Burlington, KY

Get the Code

Download or explore the source code for this lesson on GitHub

Repository

🕰️ Chapters
00:00 - Lesson Objective
00:40 - Reusing Our Avatar Upload Fields
02:40 - Reviewing Avatar Upload Logic
03:22 - Adding Poster Field Validations
04:08 - Movie Creation Cover Upload
06:48 - Movie Edit Cover Upload & Deletion
07:58 - Testing Our Cover Upload
09:15 - Moving Cover Image Upload to a Service

Join The Discussion! (3 Comments)

Please sign in or sign up for free to join in on the dicussion.

  1. Commented 1 month ago

    When testing in Postman, I encounter a "slug uniqueness error" on the third consecutive form submission without changing the input. The error occurs in the store method, which validates the request, processes the poster file, and creates a movie record. The database throws a duplicate key error because the slug already exists, violating the movies_slug_unique constraint. This likely happens because the slugify method, provided in the course, fails to generate a unique slug for repeated sub

    1

    Please sign in or sign up for free to reply

    1. Commented 1 month ago

      The issue lies in the fact that only English letters are supported, so we should first ensure that the title is in English, and then verify its uniqueness. It is recommended to use the transliteration library.

      1

      Please sign in or sign up for free to reply

      1. Commented 1 month ago

        Ah, I'm happy to hear you were able to track down the root cause! Sorry there wasn't a warning in-video about that, codthing! Locales on the slugify didn't even occur to me.

        1

        Please sign in or sign up for free to reply