title: Django Rest Framework+React JS ,unable to implement form parser (error: The submitted data was not a file. Check the encoding type on the form.)
body: <p>When I submit a form from react frontend with images server responds <code>"The submitted data was not a file. Check the encoding type on the form."</code>. When I use Django RF browsable API I can successfully add images. Will this be a problem from frontend then ?</p>
  
  <p>VIEWS.PY</p>
  
  <pre><code>class PostListCreateview(generics.ListCreateAPIView):
      queryset = Post.objects.all().order_by('id')
      serializer_class = PostSerializer
      permission_classes = [permissions.IsAuthenticatedOrReadOnly]
      parser_class = (FileUploadParser,)
      def perform_create(self, serializer):
  
          serializer.save(author=self.request.user)
  </code></pre>
  
  <p>The Post model accepts <code>title,body and pic</code> as parameters from the form POST methods.</p>
  
  <p>REACT FRONTEND </p>
  
  <pre><code>const [image,setImage] = useState(null)
  
      const handlesubmit =()=&gt;{
          let endpoint = `/api/post/`;
          apiService(endpoint,'POST',{title:title,body:body,pic:image}).then(data=&gt;
           console.log(data))};
  
      return (&lt;input type="file"  onChange={(e)=&gt;setImage(e.target.files[0])}/&gt;
                &lt;Button onClick={handlesubmit} &gt;Upload&lt;/Button&gt;)
  
  </code></pre>