title: The file "/tmp/phpHh98PX" does not exist
body: <p>I know this question has been asked many times but there is no answer that solved my problem.</p>
  <p><strong>I DON'T WANT TO USE VichUploader</strong></p>
  <p>What I want to do is very simple: save an entity with a file upload.</p>
  <ol>
  <li>I receive my data correctly</li>
  <li>The upload is done in the specified path</li>
  <li>If I comment the upload script the entity is saved well</li>
  </ol>
  <p>I can't get all the script to work, it stops on flush</p>
  <p><strong>CODE</strong></p>
  <p><em>ClientDocument.php</em></p>
  <pre><code>@ApiResource(
   ....
   *     collectionOperations={
   *         &quot;get&quot;,
   *         &quot;post&quot; = {
   *             &quot;controller&quot; = DocumentController::class,
   *             &quot;deserialize&quot; = false
   *     }})
  class ClientDocument extends PersonDocument {
  
      /**
       * @ORM\ManyToOne(targetEntity=&quot;Client&quot;, inversedBy=&quot;clientDocuments&quot;)
       */
      private ?Client $client;
  
      // Getter and Setter
  }
  </code></pre>
  <p><em>SalarieDocument.php</em></p>
  <pre><code>@ApiResource(
   ....
   *     collectionOperations={
   *         &quot;get&quot;,
   *         &quot;post&quot; = {
   *             &quot;controller&quot; = DocumentController::class,
   *             &quot;deserialize&quot; = false
   *     }})
  class SalarieDocument extends PersonDocument {
  
      /**
       * @ORM\ManyToOne(targetEntity=&quot;Salarie&quot;, inversedBy=&quot;salarieDocuments&quot;)
       */
      private ?Salarie $salarie;
  
      // Getter and Setter
  }
  </code></pre>
  <p><em>PersonDocument.php</em></p>
  <pre><code>/**
  ...
   * @ORM\InheritanceType(&quot;SINGLE_TABLE&quot;)
  ...
  class PersonDocument {
  
  private ?string $reference;
  
  * @Assert\File(
       *     maxSize=&quot;200ki&quot;,
       *     mimeTypes={&quot;application/pdf&quot;, &quot;image/jpeg&quot;, &quot;image/jpg&quot;}
       * )
       */
      private ?string $docFile;
  
  // Getters and Setters
  }
  </code></pre>
  <p><em>DocumentController.php</em></p>
  <pre><code>public function __invoke() {
  
      return $this-&gt;documentService-&gt;createPersonDocument($data, $files);
  }
  </code></pre>
  <p><em>DocumentService.php</em></p>
  <pre><code>public function createPersonDocument(array $data, array $files) {
          $client = ....
          $personDocument = $this-&gt;createEditPersonDocument(new ClientDocument(), $data);
          $personDocument = $this-&gt;upload($person, $personDocument, $files[0]);
          $client-&gt;addClientDocuments($personDocument);
          $this-&gt;manager-&gt;persist($client);
          $this-&gt;manager-&gt;flush();
  
          return $personDocument;
      }
  </code></pre>
  <p><strong>Stack</strong></p>
  <ul>
  <li>PHP 7.4</li>
  <li>Symfony 5.3</li>
  <li>Api Platform 2.6</li>
  </ul>
  <p>I didn't customize anything in php.ini (it's default), no advanced infrastructure (no docker or anything).</p>
  <p>If I <em>dump</em> my objects before the <em>$this-&gt;manager-&gt;flush();</em> everything is good</p>
  <p>Do you have any idea what is causing this error please ?</p>