Reputation: 3375
I have checked all thread with same issue but still can't find out why isn't working. I have this function
namespace App\Http\Controllers\Admin;
use App\MediaKit;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Input;
use Illuminate\Support\Facades\Redirect;
use Validator ;
use Illuminate\Support\Facades\File;
class MediaKitController extends Controller
{
public function store(Request $request)
{
$this->validate($request, [
'filename' => 'required',
'filename.*' => 'mimes:doc,pdf,docx,zip,png'
]);
if($request->hasfile('filename'))
{
foreach($request->file('filename') as $files)
{
$name = $files->getClientOriginalName();
$files->move(public_path().'/files/', $name);
$data[] = $name;
}
}
$files= new \File();
$files->filename=json_encode($data);
$files->save();
return back()->with('success', 'Your files has been successfully added');
}
When I try to save the file(s) to the database I've got the following error. The files are saved in the directory.
"Call to undefined method Illuminate\Support\Facades\File::save()"
Upvotes: 0
Views: 1973
Reputation: 2683
use Illuminate\Support\Facades\File;
to your model namespace.$files= new \File();
to $files= new File();
Upvotes: 1