Aniket Karne
Aniket Karne

Reputation: 325

Laravel passing URL to get method

http://localhost:8000/image/https://pbs.twimg.com/profile_images/443395572783800322/nXTuit5o.jpeg

i want to pass url to the route like this

ROute is like this

Route::get('/image/{url}','ImageController@uploadImageViaUrl');

Upvotes: 0

Views: 318

Answers (2)

KmasterYC
KmasterYC

Reputation: 2354

Instead of using this BAD practice

http://localhost:8000/image/https://pbs.twimg.com/profile_images/443395572783800322/nXTuit5o.jpeg

Consider to use

http://localhost:8000/image?link=https://pbs.twimg.com/profile_images/443395572783800322/nXTuit5o.jpeg

In routes.php

Route::get('/image','ImageController@uploadImageViaUrl');

In that Controller you can get img url

$img_link = request()->query('link');

Upvotes: 1

holland
holland

Reputation: 2182

I don't think it's possible like that, because basically youre extending the route with all the slashes in it. After the https part in your image url you have 5 more slashes which would give your route the following weird pattern:

Route::get('/image/{url}/{someting?!}/{someting?!}/{someting?!}/...', 'ImageController@uploadImageViaUrl');

Concider using POST requests for uploading images, maybe this post will help?

Upvotes: 0

Related Questions