Skip to content

Instantly share code, notes, and snippets.

@vyspiansky
Last active March 18, 2025 10:52
Show Gist options
  • Save vyspiansky/931524034c5423909bbf09455cd827ef to your computer and use it in GitHub Desktop.
Save vyspiansky/931524034c5423909bbf09455cd827ef to your computer and use it in GitHub Desktop.
Move file to directory in Drupal 10
<?php
use Drupal\Core\File\FileSystemInterface;
$directory = '/path/to/processed';
\Drupal::service('file_system')
->prepareDirectory($directory, FileSystemInterface::CREATE_DIRECTORY);
\Drupal::service('file_system')
->move($file->uri, $directory . '/' . $file->filename);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment