laravel getClientOriginalExtension

72

$extension = Input::file('photo')->getClientOriginalExtension();
if($request->hasFile('photos')){
if (Input::file('photos')->isValid()) {
    $file = Input::file('photos');
    $destination = 'images/Foldername'.'/';
    $ext= $file->getClientOriginalExtension();
    $mainFilename = str_random(6).date('h-i-s');
    $file->move($destination, $mainFilename.".".$ext);
    echo "uploaded successfully";
}
}
$name = Input::file('photo')->getClientOriginalName();
<form action="" method="post" enctype="multipart/form-data">
 <input type="file" name="photos">
 </form>
if ($request->hasFile('photos')) {
$files = $request->file('photos');
foreach($files as $file){
    $filename = $file->getClientOriginalName();
    $extension = $file->getClientOriginalExtension();
    $fileName = str_random(5)."-".date('his')."-".str_random(3).".".$extension;
    $destinationPath = 'images/Foldername'.'/';
    $file->move($destinationPath, $fileName);
}
}
<form action="" method="post" enctype="multipart/form-data">
 <input type="file" name="photos[]" multiple>
 </form>

Comments

Submit
0 Comments