Question: Hi I'm learning right now how to upload images to database, but I'm getting this error/notice.

```
 </select>
                <input type="text" name="nama" class="input-control" placeholder="Nama Produk" required>
                <input type="text" name="harga" class="input-control" placeholder="Harga Produk" required>
                <input type="file" name="img" class="input-control" required>
                <textarea class="input-control" name="deskripsi" placeholder="Desrkipsi"></textarea>
                <select class="input-control" name="status">
                    <option value="">--Pilih--</option>
                    <option value="1">Aktif</option>
                    <option value="0">Tidak Aktif</option>
                </select>
                <input type="submit" name="submit" value="Submit" class="btn-login">
            </form>  
            <?php 
                if(isset($_POST['submit'])){

                    $kategori   = $_POST['kategori'];
                    $nama       = $_POST['nama'];
                    $harga      = $_POST['harga'];
                    $deskripsi  = $_POST['deskripsi'];    
                    $status     = $_POST['status'];

                    $filename = $_FILES['img']['name'];
                    $tmp_name = $_FILES['img']['tmp_name'];

                }

```

the error output

```
Notice: Undefined index: img in C:\xampp\htdocs\pa_web\tambah_produk.php on line 66

```

Answer: 
You need to add `enctype="multipart/form-data"` to your form  

<https://www.php.net/manual/en/features.file-upload.post-method.php>

> 
> **Note:**
> Be sure your file upload form has attribute
> enctype="multipart/form-data" otherwise the file upload will not work.
> 
> 
>
When you want to submit file from form you should put "enctype="multipart/form-data".

```
<form "enctype="multipart/form-data" ...> 

</form>

```

Do you put it?