I want to store the values to the Database and redirect to a new page but find this error. I changed my code many times but same error is displayed. I am continuously finding this error.Please if there is any tricks to avoid the error please provide it to me.I have tried many possible things but the error is same.
Route.php
Route::get('/create', ['as'=>'creates','uses'=>'CAsController@create2']);
Route::put('/postca', 'CAsController@storing');
<?php
namespace App\Http\Controllers;
use App\CAModel;
use Illuminate\Http\Request;
class CAsController extends Controller
{
public function create2(){
return view('chartered.create');
}
public function storing(Request $request)
{
// Handle File Upload
if($request->hasFile('profile')){
// Get filename with the extension
$filenameWithExt = $request->file('profile')->getClientOriginalName();
// Get just filename
$filename = pathinfo($filenameWithExt, PATHINFO_FILENAME);
// Get just ext
$extension = $request->file('profile')->getClientOriginalExtension();
// Filename to store
$fileNameToStore= $filename.'_'.time().'.'.$extension;
// Upload Image
$path = $request->file('profile')->storeAs('public/profile', $fileNameToStore);
} else {
$fileNameToStore = 'noimage.jpg';
}
// Handle File Upload
if($request->hasFile('certificate')){
// Get filename with the extension
$filenameWithExt1 = $request->file('certificate')->getClientOriginalName();
// Get just filename
$filename1 = pathinfo($filenameWithExt1, PATHINFO_FILENAME);
// Get just ext
$extension1 = $request->file('certificate')->getClientOriginalExtension();
// Filename to store
$fileNameToStore1= $filename1.'_'.time().'.'.$extension1;
// Upload Image
$path1 = $request->file('certificate')->storeAs('public/certificate', $fileNameToStore1);
} else {
$fileNameToStore1 = 'noimage.jpg';
}
$ca = new CAModel;
$ca->fname = $request->input('fname');
$ca->lastname = $request->input('lastname');
$ca->username = $request->input('username');
$ca->city = $request->input('city');
$ca->state = $request->input('state');
$ca->zip = $request->input('zip');
$ca->phone = $request->input('phone');
$ca->email = $request->input('email');
$ca->gstno = $request->input('gstno');
$ca->website = $request->input('website');
$ca->services = $request->input('services');
$ca->profile = $fileNameToStore;
$ca->certificate = $fileNameToStore1;
$ca->save();
return redirect('/postca');
}
}
<p>Register for TaxRx.</p>
<form method="POST" action="">
@csrf
@method('put')
<div class="form-group">
<input type="text" class="form-control" placeholder="Name" style="text-transform: uppercase;" value="" readonly>
</div>
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire