title: File not uploading in Express JS using Multer received fro Editor
body: <p>I am getting the file using TinyMCE Editor. Using the paste plugin and uploading it using Express Server. I have tried using different things. But need to upload file received from TinyMCE editor</p>
  <p>Here is my front-end Code:</p>
  <pre><code>function example_image_upload_handler(blobInfo, success, failure, progress) {
      var xhr, formData;
  
  localStorage.myfile = blobInfo.blob()
  
  xhr = new XMLHttpRequest();
  xhr.withCredentials = false;
  xhr.open('POST', 'http://localhost:5000/api/upload');
  
  xhr.upload.onprogress = function (e) {
    progress(e.loaded / e.total * 100);
  };
  
  xhr.onload = function () {
    var json;
  
    if (xhr.status === 403) {
      failure('HTTP Error: ' + xhr.status, { remove: true });
      return;
    }
  
    if (xhr.status &lt; 200 || xhr.status &gt;= 300) {
      failure('HTTP Error: ' + xhr.status);
      return;
    }
  
    json = JSON.parse(xhr.responseText);
  
    if (!json || typeof json.location != 'string') {
      failure('Invalid JSON: ' + xhr.responseText);
      return;
    }
  
    success(json.location);
  };
  
  xhr.onerror = function () {
    failure('Image upload failed due to a XHR Transport error. Code: ' + xhr.status);
  };
  
  formData = new FormData();
  formData.append('file', localStorage.myfile, blobInfo.filename());
  
  xhr.send(formData);
  
  
  };
  const handleSubmit = async (e) =&gt; {
      e.preventDefault();
      console.log(&quot;hello&quot;);
      example_image_upload_handler();
      console.log(desc);
      const newPost = {
        username: user.username,
        title,
        desc,
      };
      if (file) {
        const data = new FormData();
        const filename = Date.now() + file.name;
        data.append(&quot;name&quot;, filename);
        data.append(&quot;file&quot;, file);
        newPost.photo = filename;
        try {
          console.log(&quot;hello&quot;);
          if (await axios.post(&quot;http://localhost:5000/api/upload&quot;, data)) {
            // console.log(&quot;monu&quot;);
          }
        } catch (err) {
          console.log(err);
        }
      }
      try {
        const res = await axios.post(&quot;http://localhost:5000/api/posts&quot;, newPost);
        window.location.replace(&quot;/post/&quot; + res.data._id);
      } catch (err) {
        console.log(err);
      }
    };
  
    const handleEditorChange = (e) =&gt; {
      console.log(
        'Content was updated:',
        setDesc(e.target.getContent())
      );
    }
  
    return (
      &lt;div className=&quot;write&quot;&gt;
        {file &amp;&amp; (
          &lt;img className=&quot;writeImg&quot; src={URL.createObjectURL(file)} alt=&quot;&quot; /&gt;
        )}
        &lt;form className=&quot;writeForm&quot; onSubmit={handleSubmit}&gt;
          &lt;div className=&quot;writeFormGroup&quot;&gt;
            &lt;label htmlFor=&quot;fileInput&quot;&gt;
              &lt;i className=&quot;writeIcon fas fa-plus&quot;&gt;&lt;/i&gt;
            &lt;/label&gt;
            &lt;input
              type=&quot;file&quot;
              id=&quot;fileInput&quot;
              style={{ display: &quot;none&quot; }}
              onChange={(e) =&gt; setFile(e.target.files[0])}
            /&gt;
            &lt;input
              type=&quot;text&quot;
              placeholder=&quot;Title&quot;
              className=&quot;writeInput&quot;
              autoFocus={true}
              onChange={e =&gt; setTitle(e.target.value)}
            /&gt;
          &lt;/div&gt;
  
  
  &lt;Editor
                apiKey=&quot;XXXXXXXXXXXXXXXXXXXXXXX&quot;
                initialValue=&quot;&lt;p&gt;Initial content&lt;/p&gt;&quot;
                init={{
                  height: 500,
                  menubar: 'edit',
                  selector: 'textarea',
                  plugins: [
                    'advlist autolink lists link image',
                    'charmap print preview anchor help',
                    'searchreplace visualblocks code',
                    'insertdatetime media table paste wordcount',
                    'image imagetools paste'
                  ],
                  images_upload_handler: example_image_upload_handler,
                  toolbar:
                    'undo redo | formatselect | bold italic | \
                    alignleft aligncenter alignright | \
                    bullist numlist outdent indent | image | help',
                  paste_data_images: true
                }}
                onChange={handleEditorChange}
              /&gt;
            &lt;/div&gt;
            &lt;button className=&quot;writeSubmit&quot; type=&quot;submit&quot;&gt;
              Publish
            &lt;/button&gt;
          &lt;/form&gt;
        &lt;/div&gt;
  
    );
  </code></pre>
  <p>Following is my express js upload API code:</p>
  <pre><code>const upload = multer({ storage: storage });
  app.post(&quot;/api/upload&quot;, upload.single(&quot;file&quot;), (req, res) =&gt; {
    console.log(&quot;req&quot;);
    console.log(req);
    res.status(200).json(&quot;File has been uploaded&quot;);
  });
  </code></pre>
  <p>Following is the error I am getting:</p>
  <p><a href="https://i.stack.imgur.com/QSpsm.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/QSpsm.png" alt="enter image description here" /></a></p>
  <p>Please help me with the same.</p>