We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 23383
    • 138 Posts
    ahah, I maybe found something, i stored the 1 folder on my hdd under a text file, and see :

    <b>Warning</b>:  fopen(../../../assets/files/filedownload/1): failed to open stream: Permission denied in <b>c:\program files\easyphp1-8\www\website\assets\snippets\filedownload\download.php</b> on line <b>62</b><br />
    <br />
    <b>Warning</b>:  fread(): supplied argument is not a valid stream resource in <b>c:\program files\easyphp1-8\www\website\assets\snippets\filedownload\download.php</b> on line <b>63</b><br />
    <br />
    <b>Warning</b>:  fclose(): supplied argument is not a valid stream resource in <b>c:\program files\easyphp1-8\www\website\assets\snippets\filedownload\download.php</b> on line <b>64</b><br />
    


    It’s seems strange for me : Permission denied on my own computer, with admin rights wink
    I will watch on this.
      • 15987
      • 786 Posts
      That is strange, I’m not sure why the is_dir command would not work correctly on a folder?
        • 23383
        • 138 Posts
        Don’t know too that’s why I ask for help ! wink

        I can’t get it working, it’s very embarassing, cause I don’t see where is the code problem ! I did’t find some documentation on google ><
          • 23383
          • 138 Posts
          I’ve solved the problem :
          I changed (near line 330):
          $date = date('Y-m-d', filemtime($_SERVER['DOCUMENT_ROOT'] . '/' . $getFolder.$relPath));
          $relPathParts = explode('/', $relPath);
          by this:
          if(file_exists($file['name']))
                  {
                  	$date = date('Y-m-d', filemtime($_SERVER['DOCUMENT_ROOT'] . '/' . $getFolder.$relPath));
                  }
                  $relPathParts = explode('/', $relPath);
          


          and this (+/- line 360):
          if (!is_dir($_SERVER['DOCUMENT_ROOT'] . '/' . $getFolder.$relPath . '/' . $file['name']))
          
          by this :
          if ($file['type']!='dir')
          
            • 15987
            • 786 Posts
            pikachu320,
            Glad to see you got this working. I will incorporate those changes into an updated version!

            Thanks,
            Kyle
              • 27088
              • 11 Posts
              Kyle plus all contributors, thank you for a great snippet!

              I would like authorised users to be able to delete files from a directory. Authorisation works fine, the delete link shows within the page contents however when clicked, instead of removing the file from the directory I am redirected to the 404 File Not Found page I set up in MODx.

              I am running Windows XP with WAMP5 Apache 2.0.58, PHP 4.4.2
              MODx 0.9.2.1 with FURL enabled
              FileDownload 1.7

              The behavior occurs in (Mozilla), FireFox and IE both under PHP4 & 5.

              My snippet call: [!FileDownload?getFolder=`assets/docs/short_term_experts` &tplList=`FileDownload` &useHlt=`1` &evenClass=`evenrow` &deleteGroups=`Project management` &oddClass=`oddrow` &imgLocat=`assets/templates/mollio/css/images`!]

              Folder name: ’assets/docs/short_term_experts’
              File name: ’ste New Text Document.txt’

              The ’Delete’ link is associated with the following URI:
              http://localhost/aveiro/index.php?q=23.html?act=del&name=23ae44a7bb9263f9076f7c3dbbd48e07


              When removing the MD5 from the code the link shows following URI:
              http://localhost/aveiro/index.php?q=23.html?act=del&name=assets/docs/short_term_experts/ste New Text Document.txt01154100940


              Removing size and time from the URI by changing line 75 in filedownload.inc.php
              from:
                                 $files[$fkey]['delete'] = md5($fullpath.$a['size'].$a['mtime']);

              to this:
                                 $files[$fkey]['delete'] = $fullpath;

              did not help either; still getting the 404 error page. Any ideas what may be going wrong huh

              ps downloads are working no problem!
                • 15987
                • 786 Posts
                I left out the check for friendly urls for the delete link creation so it is putting 2 ? in the url. Change the code in the snippet at line 382 to this:

                if ($canDelete) {
                  $addUrl = $modx->config['friendly_urls']? '?':'&';
                  $tpl2 = str_replace('[+delete+]','<a href="'.$currentPageLink.$addUrl.'act=del&name='.$file['delete'].'">'.$delText.'</a>',$tpl2);
                } else {
                  $tpl2 = str_replace('[+delete+]','',$tpl2);
                }
                
                  • 27088
                  • 11 Posts
                  thank you for a quick reply. i changed the code in the snippet to reflect the changes as posted by you above. however I still get the 404 error. I don’t believe above code has any bearings on the problem since the URI for the download link did not have 2 ? in the url to begin with.

                  something is playing up as I am also not able to get the filedownload counter to work when including &downloadCount=`1` in the snippet call. but I am not too worried about that, I can live without that but would like to get the ’delete’ function to work. Any other ideas?

                  Thanks.
                    • 15987
                    • 786 Posts
                    Can you post the new URI, the previous one did have 2 ?’s see below (one after index.php and one after 23.html):

                    Quote from: Shocking_blue at Aug 10, 2006, 08:55 AM

                    The ’Delete’ link is associated with the following URI:
                    http://localhost/aveiro/index.php?q=23.html?act=del&name=23ae44a7bb9263f9076f7c3dbbd48e07

                      • 27088
                      • 11 Posts
                      Ah, now I get it. Here I was looking for an instance of ’??’ Sorry spent too much time looking at code today I guess laugh
                      But your request prompted me to have a look at my FURL’s. The reason why I had that extra ’?’ in my URI was because I had set the Prefix for friendly URLs to ’index.php?q=’ tongue After having set this prefix to ` ` I was able to delete the file as per normal.

                      Thank you for that pointer in the right direction. I think I ought to step away from the screen more often to give the brain a break grin

                      Sb