can't find element plug-in that will download pdf file without requiring path prefixed to filename

Discussion in 'Professional Support' started by rpc, Aug 8, 2018.

  1. rpc

    rpc New Member

    Level: Professional
    I have an element that contains a value in the form:
    images/path/filename.pdf
    I am able to download the PDF using the plug-in type of field or fileupload, but the issue is that I want to have only the filename.pdf as the value and not have to include the relative path. It appears that the image plug-in type allows you to specify the relative path in Details-Image, so only the filename.png needs to be in the database. Is there a way to do this for a PDF file or is there a variable I could place in the database that could be defined in Fabrik to identify the path (e.g. $RelativePath/filename.pdf)?
     
  2. troester

    troester Well-Known Member Staff Member

    Level: Standard
    You could use an additional element to store only the filename (e.g a calc element or a field element filled via php form plugin).

    What do you want to achieve, why do you need this?
     
  3. rpc

    rpc New Member

    Level: Professional
    I am trying to avoid having to update 600 database entries to add the path to the existing filename.
    Also, if I need to move the location of where these files reside, I would need to update all the entries again.
     
  4. rpc

    rpc New Member

    Level: Professional
    I created a product search, each entry contains multiple text field elements that describe the product, plus two fields that reference local files. The first element is an image, which contains filename.png, that displays a picture of the item. The second element is a PDF, which contains filename.pdf, that I would like the user to be able to download the specification sheet.
    The image element specifies the file path separately, so the database only needs to contain the filename.
    The PDF requires the file path along with the filename in the database for it to download properly. I'm questioning why there isn't a way to specify a static file path so that the database only needs to contain the PDF filename, similar to how the image element works?
     
  5. cheesegrits

    cheesegrits Support Gopher Staff Member

    Level: Professional
    The short answer is "because that's the way it works". The upload element stores the path, relative to J! root.

    So I think the answer to your question, if you are using an upload element, is no, there isn't any way to just store the filename.

    If you need to change it, a single query by hand on the database would do it, using something like phpMyAdmin. You wouldn't have to edit 600 records.

    To insert a path to a bare 'filename.pdf' ...

    Code (Text):

    UPDATE yourtable SET yourelement = CONCAT('relative/path/to/folder/', yourelement)
     
    To change a path ...

    Code (Text):

    UPDATE yourtable SET yourelement = REPLACE(yourelement, 'original/relative/path/', 'new/relative/path/')
     
    Always back up your database before doing any "destructive" changes by hand.

    -- hugh
     
  6. rpc

    rpc New Member

    Level: Professional
    Yes, thank you, that will help save me some time!
     
    cheesegrits likes this.

Share This Page