Advertisement
Tatarize

Untitled

Sep 24th, 2017
262
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.61 KB | None | 0 0
  1. function makeFileManaged() {
  2.             if (!isset($_FILES['croppedfile']))
  3.                 return NULL;
  4.             $path = $_FILES['croppedfile']['tmp_name'];
  5.             if (!file_exists($path))
  6.                 return NULL;
  7.             $result_filename = $_FILES['croppedfile']['name'];
  8.             $uri = file_unmanaged_move($path, 'private://' . $result_filename, FILE_EXISTS_RENAME);
  9.             if ($uri == FALSE)
  10.                 return NULL;
  11.             $file = File::Create([
  12.                         'uri' => $uri,
  13.             ]);
  14.             $file->save();
  15.             return $file->id();
  16.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement