We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 17233
    • 15 Posts
    My site example: http://mysite.com


    on server:

    .MirrorSearch
    myfiles ---> have files here to download
    .cpanel
    .trash
    +public_ftp
    +public_html --->web user inlog here
    +www


    guest = password,username


    <a href="ftp://guest:[email protected]/files/empty_test.zip">download link for user(guest)</a>


    I get this message:

    530 Login authentication failed


    can someone help please


    many thanks

      • 6228
      • 249 Posts
      You need to place your files in a web-accessible directory in order for a direct link to work properly. In order to download from a directory outside of the web root (which I think may be the case here), you will need a proxy script.

      - Mike
        lo9on.com

        MODx Evolution/Revolution | Remote Desktop Training | Development
        • 17233
        • 15 Posts
        Many thanks for your post Mike

        do you have a script,part of a script or a link to where I can find something to use. I looked myself, and I find it strange, that so muck code for making a link.

        I worked a little, and came up with this until Monday, where I can test/change it on Server

        ------------------------
        files/link.php

        $mydir = "../files/";

        if ($handle = opendir($mydir)) {
        while (false !== ($file = readdir($handle))) {
        ?>
        <a href="<?php echo $mydir.$file ?>"><?php echo $file ?></a>
        <?php
        }
        closedir($handle);
        }

        ----------------------


        snippet


        include ($_SERVER["DOCUMENT_ROOT"]."/files/link.php");


        ---------------------------



        Many thanks Lisa you are good grin



        Anyone have another way or fix, if this does not work on server.
        That would be great







          • 6228
          • 249 Posts
          Try this:

          <?php
          $mydir = "../files/";
          if ($handle = opendir($mydir)) {
              while (false !== ($file = readdir($handle))) {
                  if ($file != '.' && $file != '..') {
          ?>
                     <a href="download.php?f=<?php echo $file ?>" target="_blank"><?php echo $file ?></a><br/>
          <?php
                  }
              }
              closedir($handle);
          }
          ?>
          



          And then create a page called download.php (or any name that suits you), have only this script available on the page:

          $filename = $_GET['f'];
          // set this to the path where your zipped files are located
          $filepath = "/path/to/your/zip/files/" . $filename;
          // a little security
          if(strpos($filename, '..') !== false || realpath($filepath) != $filepath) die();
          if (file_exists($filepath)){
              // make sure the browser knows what it's getting, and what to do with it
              header('Cache-Control: public');
              header('Content-Type: application/zip');
              header('Content-Disposition: attachment; filename=' . $filename);
              readfile($filepath);
              die(); 
          } else {
              die('Error: File not found.');
          }
          

            lo9on.com

            MODx Evolution/Revolution | Remote Desktop Training | Development