简体   繁体   中英

I want to show random picture in one image url but it show permission denied

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].");
  });

enter image description here

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM