We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 22815
    • 1,097 Posts
    Please note that FileDownload uses directory commands that access the local filesystem, and is thus restricted to listing download files on the same server as the snippet. This may be obvious, but I’m stating it here for the record.

    MODERATOR NOTE:
    A discussion started here in which a non-coder enquired about extending FileDownload to work across two domains on different hosts. This has been moved to the Wishlist thread
    Something Like FileDownload But For A Remote Server. This is not to say that such a thing is not possible, but it is outside the current remit of FileDownload and such discussion is potentially confusing to people trying to use this snippet in the manner that it was intended.
      No, I don't know what OpenGeek's saying half the time either.
      MODx Documentation: The Wiki | My Wiki contributions | Main MODx Documentation
      Forum: Where to post threads about add-ons | Forum Rules
      Like MODx? donate (and/or share your resources)
      Like me? See my Amazon wishlist
      MODx "Most Promising CMS" - so appropriate!
      • 2472
      • 151 Posts
      Hi all,

      I’ve installed FileDownload v1.7 but for some reason when i click on the generated link i get a download dialog for download.php in stead of my zip file... counter gets increased.

      I dropped the following code in my document, disabled WYSIWIG, content type text/html, Inline...
      [!FileDownload?getFolder=`assets/myDownloadables` &chkDesc=`chFileDownloadList` &tplList=`chFileDownload` &downloadCount=`1`!]


      chFileDownload chunk
      <br /><br />
      <hr>
      <ul>
        <li><strong>[+filename+]</strong> - [+description+]
        <ul>
          <li>Taille du fichier: [+sizetext+]</li>
          <li>Date: [+date+]</li>
          <li>Nombre de téléchargements: [+counter+]</li>
          <li><a href="[+link+]">Télécharger</a></li>
        </ul>
        </li>    
      </ul>
      <hr>


      chFileDownloadList chunk
      2006-08-05.zip|Les photos du BBQ Almez-Marchal.


      The result can be admired ( ahum) here: www.avander.be/index.php?id=84

      The file that should be downloaded is a zip containing some pictures from a bbq I attended, i’d like to share them with all other attendees using my modx site, but no luck so far...

      Any ideas? TIA
        A thing of beauty is a joy forever ( John Keats)
        • 4310
        • 2,310 Posts
        I’m having trouble getting any images to display.
        PHP isn’t my strong point I’m afraid.
        Everything else is working fine but no images!
        My call on the page is...
        [[FileDownload?getFolder=`assets/files/Foundation Stage` &tplList=`FileDownload` &chkDesc=`fileinfo` &useHlt=`1` &imgLocat=`assets/icons]]

        I’ve only altered the snippet here....
        // Location of images to use - leave blank if you do not want images
        $imgLocat = isset($imgLocat)? $imgLocat : 'assets/icons';
        
        // Array to set image to use for different file types
        $imgTypes = array(
                        'swf' => 'image_JPG.png',
                        'jpg' => 'imagen_JPG.ico',
                        'png' => 'file-image.png',
                        'gif' => 'file-image.png',
                        'php' => 'file-source.png',
                        'js'  => 'file-source-alt.png',
                        'pdf' => 'file-pdf.png',
                        'txt' => 'file-document.png',
                        'zip' => 'file-archive.png',
                        'parent' => 'up.png',
                        'folder' => 'folder.png',
                        'default' => 'file-generic.png'
                    );
        
        // Allows to browse through directory structure
        $browseDirectories = isset($browseDirectories)? $browseDirectories : FALSE;

        I haven’t bothered with all the filetypes until I knew it would work.
        The chunk looks like this...
        <table cellspacing='10'>
          <tr class='dwnhead'>
          <tr><th colspan='2'>Filename</th><th>Link</th><th></th><th>Description</th><th></th></tr>
            <hr>
            <tr>
                <td>[+image+]</td>
                <td>[+filename+]</td>
                <td><a href='[+link+]'target='_blank'>Load</a></td>
          <td colspan='3'>[+description+]</td></tr>
        
        <hr>
        </table>

        Any thoughts anyone ?, be gentle with me!
        I also wondered if, assuming I get the images working, could I do away with the text link and incorporate it into the image ?
        Also could I strip out the file extension of the filename when being dispalyed ?
        David
          • 10487 MODX Staff
          • 1,535 Posts
          Hi bunk58, welcome to the community smiley

          Check your snippet call, you’ve missed a backtick at the end of the &imgLocat parameter.
            Garry Nutting
            Senior Developer
            MODX, LLC

            Email: [email protected]
            Twitter: @garryn
            Web: modx.com
            • 4310
            • 2,310 Posts
            Hello Garryn,
            I take it you mean in the snippet call.
            Must have been because of the number of times I’d changed it.
            Unfortunately it hasn’t helped!
            Still no images.
            Any more ideas?
            As a by the way should I have the imgLocat set in the snippet and then in the call?
            Cheers
            David
              • 7923
              • 4,213 Posts
              Quote from: Avander_be at Aug 11, 2006, 09:51 AM

              I’ve installed FileDownload v1.7 but for some reason when i click on the generated link i get a download dialog for download.php in stead of my zip file...
              ...
              Any ideas? TIA
              Here’s a fix for this.

              Quote from: bunk58 at Aug 31, 2006, 05:19 AM

              Any more ideas?
              As a by the way should I have the imgLocat set in the snippet and then in the call?
              The settings in the snippet are defaults what you can override in the snippet call.. if the default image location is ok for you, you don’t need to define it in the snippet call. So you have copied your file type icons into assets/icons/ folder, right?

              Do you have friendly alias paths enabled by any chance? If so, maybe that’s why the images are not showing because they use relative paths what then points into wrong directory. In that case, change the following lines:

              line 334 to:

              $fileImage = '<img src="'.$modx->config['base_url'].$imgLocat.'/'.$imgTypes['parent'].'" alt="" />';


              line 356 to:

              $fileImage = '<img src="'.$modx->config['base_url'].$imgLocat.'/'.$file['image'].'" alt="" />';


              line 370 to:

              $fileImage = '<img src="'.$modx->config['base_url'] . $imgLocat . '/' . $imgTypes['folder'] . '" alt="" />';


                "He can have a lollipop any time he wants to. That's what it means to be a programmer."
                • 4310
                • 2,310 Posts
                Doze,
                Thanks for the suggestions.
                I have checked and I did upload the images to assets/icons, but I have done things worse than that!
                I don’t have friendly url’s enabled yet because I couldn’t get it to work!
                I created the FileDownload snippet again and only altered the first image in the array but it still won’t display.
                By the way I love MaxiGallery, I got that to work!
                Cheers,
                David
                  • 7923
                  • 4,213 Posts
                  When you view the source of your page, do you see the <img> tags? and how do they look? how is the path generated? if you put the path to your browser, do you see the image..?


                    "He can have a lollipop any time he wants to. That's what it means to be a programmer."
                    • 4310
                    • 2,310 Posts
                    Hi there Doze,
                    What a genius you are, I should have looked at that.
                    All looked fine, tried to load it through the browser, no go.
                    Looked at my array and realised the first letter of the image file should be a capital!!!!!!!
                    What a complete dunce I am.
                    I’m sorry to have bothered getting out of bed this morning.
                    You go round and round in circles until someone stops you.
                    Many thanks again.
                    David
                      • 3763
                      • 155 Posts
                      Hello,

                      kylej, would be nice if you can add the filesize header in a future version.
                      <?php
                      header ('Content-Length: ' . @ filesize ($path.$filename));
                      ?>


                      This will show also the size of the downloading file in the download window, like in the attached screenshot.

                      Thanks!
                      Boby
                        ...my Photo Gallery on Flickr...