Skip to content

Instantly share code, notes, and snippets.

@init90
Created August 19, 2016 08:11
Show Gist options
  • Save init90/c3e5b64bb5622206fd12d3165a9bac12 to your computer and use it in GitHub Desktop.
Save init90/c3e5b64bb5622206fd12d3165a9bac12 to your computer and use it in GitHub Desktop.
Drupal 8 file saving.
$file_data = \Drupal::request()->files->get('ava');
$file = file_get_contents($file_data);
$file = file_save_data($file);
return $file->id();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment