Jump to content

Testic

Members
  • Posts

    4
  • Joined

  • Last visited

Posts posted by Testic

  1. 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

    • Like 1
  2. 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

  3. I was not able to make this work on due to the following issue: 

     ProcessWire: ProcessUser: Secure File: Path '/' does not exist or is not writeable

    I have tried multiple directories and approaches to change permissions, but PW could simply not find the path I specified with pwd. I am running the local server on Processwire 3.0.148.

    Any suggestions?

×
×
  • Create New...