コード例 #1
0
 protected function tearDown()
 {
     TempFileUtil::removeTempFiles();
     if ($this->tempFolder !== null && is_dir($this->tempFolder)) {
         rmdir($this->tempFolder);
     }
 }
コード例 #2
0
 /**
  * {@inheritDoc}
  */
 public function boot()
 {
     /*
      * Removes all temporary files created while handling file uploads.
      * Use a shutdown function to clean up even in case of a fatal error.
      */
     register_shutdown_function(function () {
         TempFileUtil::removeTempFiles();
     });
 }
コード例 #3
0
 /**
  * @param string|null $tempDir Directory for storing temporary files. If <code>null</code>, the system's default will be used.
  * @return mixed The unserialized object.
  */
 public function getAsFile($tempDir = null)
 {
     if ($tempDir === null) {
         $tempDir = sys_get_temp_dir();
     }
     // create a temporary file with its original content
     $tempFile = tempnam($tempDir, 'craue_form_flow_serialized_file');
     file_put_contents($tempFile, base64_decode($this->content));
     TempFileUtil::addTempFile($tempFile);
     return new UploadedFile($tempFile, $this->clientOriginalName, $this->clientMimeType, $this->clientSize, null, true);
 }