Jump to content

show pdf file in website


mrkhan
 Share

Recommended Posts

Hello ,

i am working on website where i need to upload PDF file with each product, its pretty standard i think :)

here is what i am doing 

1. i have created a new file type field name "pdf_file" and assign it to product template.

for showing PDF file in website , after searching this forum i have come to this solution , please guide me if its wrong.

1. i have created a new template name "pdf"

2. i have created a new page from "pdf" template and its url is "site/pdf", also i have allow the URL Segments.

3. now from my product page i have created a link to open pdf file like this "site/pdf/page_id"

3. in "pdf.php" file i have bellow code

<?php 
$pfile1=$input->urlSegment1;
$pfile=$pages->get($pfile1);
if($pfile->pdf_file->url){
$options = array(
    'exit' => true, 
    'forceDownload' => false, 
    'downloadFilename' => '',
    );
    wireSendFile($pfile->pdf_file->url,$options);
}

when this page open i got following error

Error: Exception: File does not exist (in /Applications/XAMPP/xamppfiles/htdocs/site1/wire/core/Functions.php line 536)
#0 /Applications/XAMPP/xamppfiles/htdocs/site1/site/templates/pdf.php(18): wireSendFile(‘/site1/site...', Array)
#1 /Applications/XAMPP/xamppfiles/htdocs/site1/wire/core/TemplateFile.php(169): require('/Applications/X...')
#2 [internal function]: TemplateFile->___render()
#3 /Applications/XAMPP/xamppfiles/htdocs/site1/wire/core/Wire.php(365): call_user_func_array(Array, Array)
#4 /Applications/XAMPP/xamppfiles/htdocs/site1/wire/core/Wire.php(320): Wire->runHooks('render', Array)
#5 /Applications/XAMPP/xamppfiles/htdocs/sit1/wire/modules/PageRender.module(356): Wire->__call('render', Array)
#6 /Applications/XAMPP/xamppfiles/htdocs/site1/wire/modules/PageRender.module(356): TemplateFile->render()
#7 [internal function]: PageRender->___renderPage(Object(HookEvent))
#8 /Applications/XAMPP/xamppfiles/htdocs/sit1/wire/core/Wire.php(365): call_user_func_array(Array, Array)
#9 /Applications/XAMPP/xamppfiles/htdocs/s
This error message was shown because you are logged in as a Superuser. Error has been logged.
i am not sure i am doing proper & secure way to display PDF file on website. as i said earlier what i actually want to do is Display PDF file in new tab when click on PDF icon from website in secure way.
 
Thanks for helping always.
 
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...