php - Laravel 5.4 Upload images with their own names -


i want upload images own names. when tried, upload diffrent names. example; php0k0saj.57352.jpg (!?)

my controller;

public function post_savenews(request $request)     {         $request->all();             /* out of question         $head = $request->input('head');         $content = $request->input('content');         $keywords = $request->input('keywords'); */          $featured=$request->post_featured;         $extension=$request->post_featured->getclientoriginalextension();          $photoname = $featured . '.' . rand(11111, 99999) . '.' . $extension;         $request->post_featured->move(public_path('uploads'), $photoname);         news::create(array('head' => $head, 'content' => $content, 'keywords' => $keywords,'post_featured'=>$photoname));          return redirect()->route('index');     } 

update line.

$photoname = $featured . '.' . rand(11111, 99999) . '.' . $extension; 

with

$photoname = $request->post_featured->getclientoriginalname(); 

hope helps


Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -