<a href="path to dir">不会以PHP回声的形式下载

When I use echo to show all stuff in folder the echo function doesn´t work for download these files.

Does anybody know why it doesn´t work ? When I see source in explorer (F12) everything looks good and should work - but it doesn´t.

Here is the code:

<?php  
            $allFiles = scandir('files/');
            $files = array_diff($allFiles, array('.', '..'));

            foreach($files as $file)
                {   
                echo "<a href src='files/".$file."' download>
                        <div class='download-folder'>
                            <div class='folder-image'></div>
                            <p>".$file."</p>
                        </div>
                      </a>";
                }

         ?>   

Thanks a lot.

Remove the src from the href. src is used for images and scripts.

echo "<a href='files/".$file."' download>
        <div class='download-folder'>
            <div class='folder-image'></div>
            <p>".$file."</p>
        </div>
      </a>";

<a href src="... is the problem. <a> tags do NOT have a src.

 <a href="$pathtofile">...</a>

Change your link to '<a href="$pathtofile" download>' and it should works.

Take a look here to show the usage of download attribute.

Change this -

echo "<a href src='files/".$file."' download>

to this -

echo "<a href='files/".$file."' download>

Anchor tags do not have sources.