Forum

Thread tagged as: Question, Problem, Shop

Digital Files not being delivered

Hi

when i get to the result page following the nest running club example and code i get the file to download with a url of /shop/download/1 when i click on the link i am taken to a blank page of /site/shop/download/1 as there is no file there.

i have created the bucket and the files are being uploaded to the bucket when i create a product file in the perch backend

'shop' => array(
            'web_path'  => '/shop/download',
            'file_path' => realpath(PERCH_RESFILEPATH.'/../../../shop_files'),
        )

i have added the bucket to the /shop/products/file.html

<!--* Predefined fields - these are useful to keep. *-->
<perch:shop id="fileTitle" type="text" label="Title" order="1" />
<perch:shop id="fileSlug" type="slug" for="fileTitle" />
<perch:shop id="file" label="File" type="file" order="2" bucket="shop" />
<!--* Feel free to add your own fields or change the order *-->

i have changed the files_list.html href to

<li>
        <a href="/shop/download/<perch:shop id="fileID" />" class="download">Download <perch:shop id="fileTitle" type="text" label="Title" order="1" /></a>
    </li>

added a download purchased files page with shop/download/[i:file] as the url and the page as

<?php
    // config
    $url_param   = 'file';


    // By default, deny downloads unless we've proved the member is allowed this file.
    $allow_download = false;


    // Check a member is logged in and has purchased the file
    if (perch_member_logged_in() && perch_shop_customer_has_purchased_file(perch_get($url_param))) {
        $allow_download = true;
    }

    // Deliver the file.
    if ($allow_download) {
        perch_shop_download_file(perch_get($url_param));
    }

    exit;

but i do not get the file just a blank page.

any idea on what i am doing wrong. There are no errors on the server that i can see,

Regards,

Brett

Brett Warne

Brett Warne 0 points

  • 5 years ago
Rachel Andrew

Rachel Andrew 394 points
Perch Support

Are you getting to that page if you echo something out to it?

You will need to work out where it is going wrong by just stepping through a debugging process until you find out if the issue is that the page is being reached but the download is being denied or the page is not being reached at all.

Hi

yes i am getting to the page i added

<?php
  // config
  $url_param     = 'file';

  // Check a member is logged in and has purchased the file
  if (perch_member_logged_in()) { echo "logged in";
    if (perch_shop_customer_has_purchased_file(perch_get($url_param))) {
      perch_shop_download_file(perch_get($url_param));  
      echo  perch_get($url_param);  
    }
  }

  exit;


and i get logged in 1

is it the file path of the server. i ma testing on our client test server that has a heap of sub domains. everything else perch related works fine on it though. I have tried adding the shop_files folder aboove the public html folder and in it changing the file_path in the buckets.html file.

Regards

Brett

Drew McLellan

Drew McLellan 2638 points
Perch Support

Does your server have the Fileinfo extension installed? If not it may be that your server is unable to detect the mime type of the file.

You are a legend.. can you add it to the members and shop requirements.

Regards
Brett

Drew McLellan

Drew McLellan 2638 points
Perch Support

It's not a requirement, but if that process is failing it is the solution.