I needed to upload multiple image as an array and for that i set up my controller like this:
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Detail;
class DetailController extends Controller
{
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
//
$data=Detail::all();
return view('details.index',compact('data'));
}
/**
* Show the form for creating a new resource.
*
* @return \Illuminate\Http\Response
*/
public function create()
{
//
$data=Detail::all();
return view('details.create',compact('data'));
}
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store(request $request) {
$input=$request->all();
if($files=$request->file('images')){
foreach($files as $file){
$name=$file->getClientOriginalName();
$file->move('image',$name);
$input['images']=$name;
}
}
Detail::create($input);
return redirect('/details');
}
And my route is:
Route::resource('/details','DetailController');
Doing so I have become to able store the selected images for upload form form in public folder ie, Public/image. But only one image is stored in database like this.Database image . Is it okay if only one among the selected images stored in DB and rest are stored in public. If okay then how can i access/display all the images in the show page. Thanks.
from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2mrTGF8
via IFTTT
Aucun commentaire:
Enregistrer un commentaire