i want to make a route to return image file like https://example.com/t.jpg but when I reload the page, the image changes randomly or is there any other way of code similar to this function?
Route::get('t.jpg',function(){
$images=['a.jpg','b.jpg','c.jpg'];
$randimage=shuffle($images);
return readfile("images/.$images[0].");
});
Your concatenation is wrong. Try the following:
Route::get('t.jpg',function(){
$images=['a.jpg','b.jpg','c.jpg'];
$randimage=shuffle($images);
**return readfile("images/" . $images[0]);**
});
i solved the problem
Route::get('t.jpg',function(){
$images=['a.jpg','b.jpg','c.jpg'];
$randimage=shuffle($images);
return Redirect::to("images/" . $images[0]);
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.