How to allow special characters in laravel route?

I have a project on Laravel, I have to make a GET request with the full outline of the images in the url. But the laravel route does not allow this, I looked through the documentation. But cannot find anything to allow special characters in the route.

GET request : http://example.com/images/"['http://def.com/x.jpg','http://ghi.com/y.png']"

how to resolve such a request in a Laravel route.

+4
source share
1 answer

You must use the entire route as shown below:

//routes.php
Route::get('images/{imageList?}', 'ExampleController@saveImages')
    ->where('imageList', '(.*)');

And then in your controller process the images as usual:

//controller 
class ExampleController extends Controller {

    public function saveData($imageList = null){
        if($imageList){
            //do stuff 
        }
    }

}

And it looks like you were not thorough in your search, because this is in the documentation on the right here

+9
source

Source: https://habr.com/ru/post/1620765/


All Articles