We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 15987
    • 786 Posts
    This is an auto-generated support/comment thread for FileDownload.

    Use this forum to post any comments about this addition or any questions you have regarding its use.

    Brief Description:
    FileDownload gets a list of files from a directory and displays them for download.
      • 21112
      • 156 Posts
      Love the snippet, very useful! I’ve encountered a problem, however.

      I have a file in a documents directory called Talentedandgiftedstudents.doc. The file icon for this file does not appear. I suspect this is because the script thinks it is a .gif file. I checked this by removing "gifted" from the file name and it displayed correctly. I have no file type image specified for .gif files. Is there a way around this problem? I can’t rename the file as it is the official title of the school policy and thus the policy document.

      Your help is appreciated.
        • 15987
        • 786 Posts
        neilcreek, good find. There was an error in how the extension was getting pulled off of the filename. I have fixed it and you can get the latest version from the repository (just use the link in the first post). Let me know if it works for you or if there are any other issues.

        Thanks,
        Kyle
          • 21112
          • 156 Posts
          Thanks for the quick response.

          I updated the snippet with the version linked to in the first post, but now I am getting a new error. Have I missed a step perhaps? This appears in place of the file list:

          Warning: Unterminated comment starting line 191 in /home/orioscom/public_html/wip/ppps/manager/includes/document.parser.class.inc.php(705) : eval()’d code on line 191

          Any suggestions?
            • 15987
            • 786 Posts
            Did you change any code in the snippet? I looked at the code and there is a comment on line 190 but it is teminated correctly. If you changed the image array, check to make sure it is setup right.
              • 21112
              • 156 Posts
              I did alter the image array:

              // Array to set image to use for different file types
              $imgTypes = array(
                              'jpg' => 'file-image.png',
                              'png' => 'file-image.png',
                              'gif' => 'file-image.png',
                              'php' => 'file-source.png',
                              'js'  => 'file-source-alt.png',
                              'pdf' => 'file-pdf.gif',
                              'doc' => 'file-word.gif',
                              'txt' => 'file-document.png',
                              'zip' => 'file-archive.png',
                              'parent' => 'up.png',
                              'folder' => 'folder.png',
                              'default' => 'file-generic.png',
                          );


              All i did was to add a "doc" format and change the filename for pdf to a .gif file. I think this looks okay, can you see anything wrong? This is the only change I made to the snippet code.
                • 15987
                • 786 Posts
                remove the comma after file-generic.png

                this doesn’t cause an error but should be removed. Can you try copying the code in again. and check line 191 it shold look like this:

                189 /*******************************************************************************
                190   Do not modify below this line
                191 *******************************************************************************/
                
                  • 21112
                  • 156 Posts
                  I should have tried copying the code again before I posted! That fixed it, thanks smiley Sorry to waste your time!

                  The file type image for the file in question is now displaying correctly, thank you very much!
                    • 15987
                    • 786 Posts
                    Glad to hear it is working now. Thanks for finding the image bug!
                      • 4209
                      • 22 Posts
                      This is just for the note that I can only call a directory this way on my server (1and1.com):

                      getFolder=`./assets/js`
                      (with the dot and slash before them all)

                      ...or else it doesn’t work at all. Maybe it’s just the server’s configuration, but anyways, maybe other people get this as well.

                      Congratulations, this tool is really useful!
                        bs.i.d..e...s....
                        Brazilian Portuguese Translator