mardi 26 septembre 2017

Form does not redirect to action url if there is a validation error

I am having a problem with uri action in laravel.

When I submitted the form, it redirects to the full url if it is successful. But if there is an error, it remains to the current url address.

example:

The current URL is : http://localhost:8000/test?url=test_sample

and my form looks like below:

<form action="" method="POST" enctype="multipart/form-data"> 
  
  <input type="file" name="pdf_file"> 
 <input type="submit" name="submit" value="Submit"/>
</form>

If the above form contains an error, it will just remain to test?url=test_sample url. If it is successful, it redirects to test?url=action

EDIT

Controller

class MyFormController extends Controller
{
   public function uploadfile(Request $request)
   {    
       $this->validate($request, [  
           'pdf_file' => 'required|mimes:pdf|max:5000'
       ]);

       return 'uploaded';
   }
}

web.php

Route::post('/test', 'MyFormController@uploadfile');

I need this feature to take effect on my site.

Does anybody know?



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2xykJRZ
via IFTTT

Aucun commentaire:

Enregistrer un commentaire