Testic Posted February 12, 2020 Share Posted February 12, 2020 23 minutes ago, k07n said: U need absolute/relative filepath but not url. Ex: /var/www/secure/ or c:\www\secure or something like ./../secure if U use windows local server and linux production server Thanks for your reply, K07n! I have another question, if I may... I simply inserted . as path, which creates a permission-restricted path in my httpdocs. However, I would like to redirect its location to the relative path: ./../secured-files-dir Unfortunately whenever I insert anything except . as path, I still get the same error: ProcessWire: ProcessUser: Secure File: Path '/' does not exist or is not writeable Link to comment Share on other sites More sharing options...
k07n Posted February 12, 2020 Share Posted February 12, 2020 10 minutes ago, Testic said: I would like to redirect its location to the relative path: ./../secured-files-dir So you need "secured-files-dir" directory on the same level as your site root: - www -- your-site-root -- secured-files-dir 2 1 Link to comment Share on other sites More sharing options...
Testic Posted February 26, 2020 Share Posted February 26, 2020 On 3/7/2016 at 8:47 AM, Wanze said: Hi Ralf, I would do this by passing the internal position of the file in the array, e.g. foreach ($pdffiles as $i => $pf) { $content .= "<a href='{$page->url}?fid={$i}' title='{$pf->name}'>$pf->name</a> ($pf->filesizeStr)<br />"; } Then you can grab the file with this ID: if ($input->get->fid) { $file = $page->file->eq((int) $input->get->fid); if ($file) { $file->download(); } } Cheers Hi there, I have been trying for days, but unfortunately without any good results.. Within my website users log in, and each user has personal files he/she can download. Everything works perfectly thanks to the module, however I cannot wrap my head around the following: - On the 'overview' page, the user can see an overview of their files after they logged in. Lets call this page 'overview.php.' - On the 'download' page, the module's API is called.overview.php: // files are placed in a repeaterfield that contains the 'securefile' and a 'title' field. <?php foreach ($user->fileRepeater as $id => $f): ?> <a href="/download?id=<?= $id ?>"> Download button </a> <?php endforeach ?> download.php: <?php secureFile = $user->fileRepeater->eq($input->get->id)->file; $secureFile->isDownloadable(); $secureFile->download(); ?> Unfortunately, this does not work for me. The page URL does not pass the $id query parameter, it simply redirects to '/download.' If anyone has any ideas.. I am very much open to it! (edit) Solution: Some problems have simple solutions.. download.php wasn't working due to the URL ending incorrectly.. As I wanted to pass as specific ID through $input->get->id, it simply didn't pass the id because the URL ended with a slash.. Solved it by going to the template in question within PW > URLs > Should page URLs end with a slash > No 1 Link to comment Share on other sites More sharing options...
cb2004 Posted May 28, 2020 Share Posted May 28, 2020 Still love this module @Wanze. Does anynody elses files stay on the filesystem when deleted? Link to comment Share on other sites More sharing options...
cb2004 Posted May 29, 2020 Share Posted May 29, 2020 I cant seem to get downloadFilename to work with this, anybody else? $secureFile = $pages->get((int) $input->urlSegment1)->filesSecure->eq((int) $input->urlSegment2); $options = array( 'forceDownload' => false, 'downloadFilename' => $secureFile->basename ); if($secureFile) $secureFile->download($options); else throw new Wire404Exception(); It just comes in as 'download' Link to comment Share on other sites More sharing options...
cb2004 Posted May 29, 2020 Share Posted May 29, 2020 Just as I was about to call it a night, here it is: $secureFile = $pages->get((int) $input->urlSegment1)->filesSecure->findOne("basename=$input->urlSegment2"); $options = array( 'forceDownload' => false ); if($secureFile) $secureFile->download($options); else throw new Wire404Exception(); 1 Link to comment Share on other sites More sharing options...
tires Posted September 8, 2020 Share Posted September 8, 2020 Hey! What is the easiest way to use this module? I output my file field like this: foreach($page->myfilefield as $file) { echo '<a href='.$file.download().'>download file</a>'; } This doesn't work very well ... So what is the right way to use it? Thanks! Link to comment Share on other sites More sharing options...
horst Posted September 8, 2020 Share Posted September 8, 2020 if you are in PHP scope here, you cannot use the dot ($file.download()) but need to use -> for $file->download() Link to comment Share on other sites More sharing options...
tires Posted September 8, 2020 Share Posted September 8, 2020 2 hours ago, horst said: if you are in PHP scope here, you cannot use the dot ($file.download()) but need to use -> for $file->download() Thanks! But it works with neither with the dot . nor with the arrow -> $file->download() The download of the first file start immediately ... Link to comment Share on other sites More sharing options...
cb2004 Posted February 3, 2021 Share Posted February 3, 2021 Hey all. Currently getting an error message with later versions of ProcessWire, not sure when this started. When trying to edit a field: Fatal Error: Uncaught Error: Call to a member function getOptions() on null in site/modules/FieldtypeSecureFile/FieldtypeSecureFile.module:205 Guessing this crept in when the file/image fields were refactored. Uncommenting line 205 seems to work, not sure what effects it may have for now. Not sure if you are still maintaining this @Wanze but I use it on loads of sites. 2 Link to comment Share on other sites More sharing options...
csaggo.com Posted March 29, 2021 Share Posted March 29, 2021 On 2/3/2021 at 12:27 PM, cb2004 said: Hey all. Currently getting an error message with later versions of ProcessWire, not sure when this started. When trying to edit a field: Fatal Error: Uncaught Error: Call to a member function getOptions() on null in site/modules/FieldtypeSecureFile/FieldtypeSecureFile.module:205 Guessing this crept in when the file/image fields were refactored. Uncommenting line 205 seems to work, not sure what effects it may have for now. Not sure if you are still maintaining this @Wanze but I use it on loads of sites. +1 its a cool module, uncommenting works for me too, but i wonder if the module is still active. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now