Advertisement
Guest User

Untitled

a guest
Apr 27th, 2017
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. $file_image='/var/www/html/drupal/sites/default/files/2017-04/images.jpeg';
  2.  
  3. $file_content = file_get_contents($file_image);
  4.  
  5. $directory = 'public://Image/';
  6.  
  7. file_prepare_directory($directory, FILE_CREATE_DIRECTORY);
  8.  
  9. $file_image = file_save_data($file_content, $directory . basename($file_image), FILE_EXISTS_REPLACE);
  10.  
  11. $user = User::create([
  12.  
  13. 'name' =>'user',
  14.  
  15. 'mail' => 'user@gmail.com',
  16.  
  17. 'pass' => 'password',
  18.  
  19. 'status' => 1,
  20.  
  21. 'roles' => array('editor','administrator'),
  22.  
  23. 'user_picture' => array('target_id' =>$file_image->id()),
  24.  
  25. 'timezone'=> 'Indian/Christmas'
  26.  
  27. ]);
  28.  
  29. $user->save();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement