title: How to upload image using django rest framework and angular?
body: <p>I am working on a project where i am using django rest framework as backend and angular 6 as frontend. I am trying to upload a image from angular form. but it shows error ["The type of the image couldn't be determined."] when try to post data.</p>
  
  <p>This is for my personal project which i want to develop using DRF,Angular and MySQL.</p>
  
  <p>models.py</p>
  
  <pre><code>from django.db import models
  from datetime import datetime
  
  
  class Category(models.Model):
    cat_name = models.CharField(max_length=200)
    parent_cat_id = models.IntegerField()
    description = models.TextField()
    cat_image = models.ImageField(upload_to='images/%Y/%m/%d/')
    active = models.BooleanField()
    create_date = models.DateTimeField(default=datetime.now)
  
   def __str__(self):
      return self.cat_name
  
   class Meta:
      db_table = "category"
  </code></pre>
  
  <p>serializers.py</p>
  
  <pre><code>from drf_extra_fields.fields import Base64ImageField
  from rest_framework import serializers
  
  from .models import Category
  
  
  class CategorySerializer(serializers.ModelSerializer):
    cat_image = Base64ImageField()
  
    class Meta:
      model = Category
      fields = ('id', 'cat_name', 'description', 'parent_cat_id', 'cat_image', 'active')
  </code></pre>
  
  <p>category.service.ts</p>
  
  <pre><code>createCategories(category) {
  return this.http.post(this.globalService.baseUrl + 'Category/', 
  category).subscribe(res =&gt; console.log('saved', res));
  </code></pre>
  
  <p>}</p>