mardi 25 septembre 2018

insertion is not working without image upload

I am submitting a form and insert all data of that form into database in which i am including name,email,image, some other textboxes etc now problem comes when m not uploading any image so form is not inserting any data like name,email into database. but if m uploading any image so my insertion query is working but its not required field so may be users can leave it empty how to insert data without upload any image ..

my controller file code public function insert(Request $request) {

    $username = $request->input('userName');
    $useremail = $request->input('userEmail');
    $symptoms = $request->input('symptoms');
    $diagnosis = $request->input('diagnosis');
    $message = $request->input('userMessage');
    $status = 0;
    $fees= $request->input('fees');


//upload image

    $path = public_path(). '\images/'; //image path
    $imageName = time().'.'.request()->prescriptionFile->getClientOriginalExtension(); // image name
    $fullImagePath = $path.''.$imageName; //full image path with image namt
    request()->prescriptionFile->move(public_path('images'), $imageName); 

//end upload image

//insert query

     //review table  
    $data = array('review_user'=>$username,'review_mail'=>$useremail,'prescription_file'=>$fullImagePath,'symptoms'=>$symptoms,'diagnosis'=>$diagnosis,'review_description'=>$message,'status'=>$status,'doctor_fees'=>$fees);
    DB::table('reviews')->insert($data);


    return back();

}



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire