Display latest image in directory ending in

后端 未结 2 376
情深已故
情深已故 2021-01-28 12:11

I\'d like to display the last modified image in a directory that ends in a specific way.

I have it working to display the last file in the directory I only don\'t know h

2条回答
  •  长发绾君心
    2021-01-28 12:58

    That is my way, resolving this issue, I am not a programmer, it is try on error product :)

    I used it in a wordpress installation and had to install the plugin Allow PHP in Posts and Pages (thats why the php tags are different, normally instead of [PHP] [/PHP])


    [PHP]
    global $path;    // path to directory has to be global, using it later in html
    
    $dir = "Planetwebcam/";
    
    $files = scandir($dir, 1);                // read directory backkwards
    
    $picture = ($files[0]);                   // get las picture file name
    
    $path = "http://www.yourdomain.ch/Planetwebcam/$picture";
    
    [/PHP]
    
    
    
    Last picture
    

提交回复
热议问题