Not able to save generated pdf on my remote server









up vote
0
down vote

favorite












I am trying to save generated pdf in custom folder but its not saving. I want to pdf to send as attachment in email
Here is my code generate and save pdf



public function email($timestamp=0, $load_id=0, $type=0)
$this->load->library('tcpdf/Pdf');
$pdf = new Pdf('P', 'mm', 'LETTER', true, 'UTF-8', false);
$pdf->SetTitle('Document');
$pdf->setPrintHeader(false);
$pdf->setPrintFooter(false);
$pdf->SetHeaderMargin(10);
$pdf->SetLeftMargin(10);
$pdf->SetRightMargin(10);
$pdf->SetTopMargin(10);
$pdf->SetAutoPageBreak(true, 25);
$pdf->SetAuthor('Author');
$pdf->SetDisplayMode('real', 'default');
$pdf->Write(5, 'Cal Sierra Load Document'); // add a page
$pdf->AddPage();
// $carriers = $this->admin_model->getCarriers(array(), array(), 0,0,1,"","","",1);
$load=$this->admin_model->getLoad($load_id);
$pickupDrops=$this->admin_model->getPickupDrops(0,0,1,0,$load_id);
$loadPickups=array();
$loadDrops=array();
if(!empty($pickupDrops))
foreach($pickupDrops as $row)
if($row['type']==1)
$loadPickups=$row;
else
$loadDrops=$row;



$data['load'] = $load;
$data['loadPickups'] = $loadPickups;
$data['loadDrops'] = $loadDrops;
// $data['carriers'] = $carriers;
$data['settings'] = $this->settings_model->getSettingsFile();
$data['currentTime'] = $timestamp;

// echo "<pre>";
// print_r($data);
// exit();

switch ($type)
case 1:
$html = $this->load->view('documents/doc1', $data, true);
break;
case 2:
$html = $this->load->view('documents/doc2', $data, true);
break;
case 3:
$html = $this->load->view('documents/doc3', $data, true);
break;
default:


$pdf->Output('custom'.'Document.pdf', 'F');
$this->Output("custom");

exit();



I am not sure where put my folder to pdf i am also adding my folder layout picture https://i.stack.imgur.com/tUadw.png










share|improve this question

























    up vote
    0
    down vote

    favorite












    I am trying to save generated pdf in custom folder but its not saving. I want to pdf to send as attachment in email
    Here is my code generate and save pdf



    public function email($timestamp=0, $load_id=0, $type=0)
    $this->load->library('tcpdf/Pdf');
    $pdf = new Pdf('P', 'mm', 'LETTER', true, 'UTF-8', false);
    $pdf->SetTitle('Document');
    $pdf->setPrintHeader(false);
    $pdf->setPrintFooter(false);
    $pdf->SetHeaderMargin(10);
    $pdf->SetLeftMargin(10);
    $pdf->SetRightMargin(10);
    $pdf->SetTopMargin(10);
    $pdf->SetAutoPageBreak(true, 25);
    $pdf->SetAuthor('Author');
    $pdf->SetDisplayMode('real', 'default');
    $pdf->Write(5, 'Cal Sierra Load Document'); // add a page
    $pdf->AddPage();
    // $carriers = $this->admin_model->getCarriers(array(), array(), 0,0,1,"","","",1);
    $load=$this->admin_model->getLoad($load_id);
    $pickupDrops=$this->admin_model->getPickupDrops(0,0,1,0,$load_id);
    $loadPickups=array();
    $loadDrops=array();
    if(!empty($pickupDrops))
    foreach($pickupDrops as $row)
    if($row['type']==1)
    $loadPickups=$row;
    else
    $loadDrops=$row;



    $data['load'] = $load;
    $data['loadPickups'] = $loadPickups;
    $data['loadDrops'] = $loadDrops;
    // $data['carriers'] = $carriers;
    $data['settings'] = $this->settings_model->getSettingsFile();
    $data['currentTime'] = $timestamp;

    // echo "<pre>";
    // print_r($data);
    // exit();

    switch ($type)
    case 1:
    $html = $this->load->view('documents/doc1', $data, true);
    break;
    case 2:
    $html = $this->load->view('documents/doc2', $data, true);
    break;
    case 3:
    $html = $this->load->view('documents/doc3', $data, true);
    break;
    default:


    $pdf->Output('custom'.'Document.pdf', 'F');
    $this->Output("custom");

    exit();



    I am not sure where put my folder to pdf i am also adding my folder layout picture https://i.stack.imgur.com/tUadw.png










    share|improve this question























      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite











      I am trying to save generated pdf in custom folder but its not saving. I want to pdf to send as attachment in email
      Here is my code generate and save pdf



      public function email($timestamp=0, $load_id=0, $type=0)
      $this->load->library('tcpdf/Pdf');
      $pdf = new Pdf('P', 'mm', 'LETTER', true, 'UTF-8', false);
      $pdf->SetTitle('Document');
      $pdf->setPrintHeader(false);
      $pdf->setPrintFooter(false);
      $pdf->SetHeaderMargin(10);
      $pdf->SetLeftMargin(10);
      $pdf->SetRightMargin(10);
      $pdf->SetTopMargin(10);
      $pdf->SetAutoPageBreak(true, 25);
      $pdf->SetAuthor('Author');
      $pdf->SetDisplayMode('real', 'default');
      $pdf->Write(5, 'Cal Sierra Load Document'); // add a page
      $pdf->AddPage();
      // $carriers = $this->admin_model->getCarriers(array(), array(), 0,0,1,"","","",1);
      $load=$this->admin_model->getLoad($load_id);
      $pickupDrops=$this->admin_model->getPickupDrops(0,0,1,0,$load_id);
      $loadPickups=array();
      $loadDrops=array();
      if(!empty($pickupDrops))
      foreach($pickupDrops as $row)
      if($row['type']==1)
      $loadPickups=$row;
      else
      $loadDrops=$row;



      $data['load'] = $load;
      $data['loadPickups'] = $loadPickups;
      $data['loadDrops'] = $loadDrops;
      // $data['carriers'] = $carriers;
      $data['settings'] = $this->settings_model->getSettingsFile();
      $data['currentTime'] = $timestamp;

      // echo "<pre>";
      // print_r($data);
      // exit();

      switch ($type)
      case 1:
      $html = $this->load->view('documents/doc1', $data, true);
      break;
      case 2:
      $html = $this->load->view('documents/doc2', $data, true);
      break;
      case 3:
      $html = $this->load->view('documents/doc3', $data, true);
      break;
      default:


      $pdf->Output('custom'.'Document.pdf', 'F');
      $this->Output("custom");

      exit();



      I am not sure where put my folder to pdf i am also adding my folder layout picture https://i.stack.imgur.com/tUadw.png










      share|improve this question













      I am trying to save generated pdf in custom folder but its not saving. I want to pdf to send as attachment in email
      Here is my code generate and save pdf



      public function email($timestamp=0, $load_id=0, $type=0)
      $this->load->library('tcpdf/Pdf');
      $pdf = new Pdf('P', 'mm', 'LETTER', true, 'UTF-8', false);
      $pdf->SetTitle('Document');
      $pdf->setPrintHeader(false);
      $pdf->setPrintFooter(false);
      $pdf->SetHeaderMargin(10);
      $pdf->SetLeftMargin(10);
      $pdf->SetRightMargin(10);
      $pdf->SetTopMargin(10);
      $pdf->SetAutoPageBreak(true, 25);
      $pdf->SetAuthor('Author');
      $pdf->SetDisplayMode('real', 'default');
      $pdf->Write(5, 'Cal Sierra Load Document'); // add a page
      $pdf->AddPage();
      // $carriers = $this->admin_model->getCarriers(array(), array(), 0,0,1,"","","",1);
      $load=$this->admin_model->getLoad($load_id);
      $pickupDrops=$this->admin_model->getPickupDrops(0,0,1,0,$load_id);
      $loadPickups=array();
      $loadDrops=array();
      if(!empty($pickupDrops))
      foreach($pickupDrops as $row)
      if($row['type']==1)
      $loadPickups=$row;
      else
      $loadDrops=$row;



      $data['load'] = $load;
      $data['loadPickups'] = $loadPickups;
      $data['loadDrops'] = $loadDrops;
      // $data['carriers'] = $carriers;
      $data['settings'] = $this->settings_model->getSettingsFile();
      $data['currentTime'] = $timestamp;

      // echo "<pre>";
      // print_r($data);
      // exit();

      switch ($type)
      case 1:
      $html = $this->load->view('documents/doc1', $data, true);
      break;
      case 2:
      $html = $this->load->view('documents/doc2', $data, true);
      break;
      case 3:
      $html = $this->load->view('documents/doc3', $data, true);
      break;
      default:


      $pdf->Output('custom'.'Document.pdf', 'F');
      $this->Output("custom");

      exit();



      I am not sure where put my folder to pdf i am also adding my folder layout picture https://i.stack.imgur.com/tUadw.png







      codeigniter






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 9 at 20:13









      Aman

      15




      15






















          1 Answer
          1






          active

          oldest

          votes

















          up vote
          0
          down vote













          Try adding a more complete path to the output function. Something like:



          $pdf->output(FCPATH . "my/directory/path/" . "pdfName.pdf", 'F');





          share|improve this answer




















          • $pdf->Output(FCPATH . 'home/cal_user/calsierra/uploads/docs/" . "Document.pdf', 'F'); exit();
            – Aman
            Nov 14 at 15:23










          • I added like this but it just open the new window without saving the pdf
            – Aman
            Nov 14 at 15:24










          • and it gives no error
            – Aman
            Nov 14 at 15:27










          • Make sure your path is correct. It may help to var_dump(FCPATH) so that you see where it is going. Just a note, if you are not trying to save this in your applications directory you won't be able to use FCPATH. You will have to write the full path yourself.
            – Colby Boren
            Nov 14 at 17:13










          • finally got it working $filename = 'Document.pdf'; $pdfFilePath = "/var/www/html/calsierra/uploads/docs/$filename"; $pdf->writeHTML($html, true, false, true, false, ''); $pdf->Output($pdfFilePath, 'F');
            – Aman
            Nov 14 at 17:47











          Your Answer






          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "1"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













           

          draft saved


          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53232712%2fnot-able-to-save-generated-pdf-on-my-remote-server%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          up vote
          0
          down vote













          Try adding a more complete path to the output function. Something like:



          $pdf->output(FCPATH . "my/directory/path/" . "pdfName.pdf", 'F');





          share|improve this answer




















          • $pdf->Output(FCPATH . 'home/cal_user/calsierra/uploads/docs/" . "Document.pdf', 'F'); exit();
            – Aman
            Nov 14 at 15:23










          • I added like this but it just open the new window without saving the pdf
            – Aman
            Nov 14 at 15:24










          • and it gives no error
            – Aman
            Nov 14 at 15:27










          • Make sure your path is correct. It may help to var_dump(FCPATH) so that you see where it is going. Just a note, if you are not trying to save this in your applications directory you won't be able to use FCPATH. You will have to write the full path yourself.
            – Colby Boren
            Nov 14 at 17:13










          • finally got it working $filename = 'Document.pdf'; $pdfFilePath = "/var/www/html/calsierra/uploads/docs/$filename"; $pdf->writeHTML($html, true, false, true, false, ''); $pdf->Output($pdfFilePath, 'F');
            – Aman
            Nov 14 at 17:47















          up vote
          0
          down vote













          Try adding a more complete path to the output function. Something like:



          $pdf->output(FCPATH . "my/directory/path/" . "pdfName.pdf", 'F');





          share|improve this answer




















          • $pdf->Output(FCPATH . 'home/cal_user/calsierra/uploads/docs/" . "Document.pdf', 'F'); exit();
            – Aman
            Nov 14 at 15:23










          • I added like this but it just open the new window without saving the pdf
            – Aman
            Nov 14 at 15:24










          • and it gives no error
            – Aman
            Nov 14 at 15:27










          • Make sure your path is correct. It may help to var_dump(FCPATH) so that you see where it is going. Just a note, if you are not trying to save this in your applications directory you won't be able to use FCPATH. You will have to write the full path yourself.
            – Colby Boren
            Nov 14 at 17:13










          • finally got it working $filename = 'Document.pdf'; $pdfFilePath = "/var/www/html/calsierra/uploads/docs/$filename"; $pdf->writeHTML($html, true, false, true, false, ''); $pdf->Output($pdfFilePath, 'F');
            – Aman
            Nov 14 at 17:47













          up vote
          0
          down vote










          up vote
          0
          down vote









          Try adding a more complete path to the output function. Something like:



          $pdf->output(FCPATH . "my/directory/path/" . "pdfName.pdf", 'F');





          share|improve this answer












          Try adding a more complete path to the output function. Something like:



          $pdf->output(FCPATH . "my/directory/path/" . "pdfName.pdf", 'F');






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 13 at 21:31









          Colby Boren

          838




          838











          • $pdf->Output(FCPATH . 'home/cal_user/calsierra/uploads/docs/" . "Document.pdf', 'F'); exit();
            – Aman
            Nov 14 at 15:23










          • I added like this but it just open the new window without saving the pdf
            – Aman
            Nov 14 at 15:24










          • and it gives no error
            – Aman
            Nov 14 at 15:27










          • Make sure your path is correct. It may help to var_dump(FCPATH) so that you see where it is going. Just a note, if you are not trying to save this in your applications directory you won't be able to use FCPATH. You will have to write the full path yourself.
            – Colby Boren
            Nov 14 at 17:13










          • finally got it working $filename = 'Document.pdf'; $pdfFilePath = "/var/www/html/calsierra/uploads/docs/$filename"; $pdf->writeHTML($html, true, false, true, false, ''); $pdf->Output($pdfFilePath, 'F');
            – Aman
            Nov 14 at 17:47

















          • $pdf->Output(FCPATH . 'home/cal_user/calsierra/uploads/docs/" . "Document.pdf', 'F'); exit();
            – Aman
            Nov 14 at 15:23










          • I added like this but it just open the new window without saving the pdf
            – Aman
            Nov 14 at 15:24










          • and it gives no error
            – Aman
            Nov 14 at 15:27










          • Make sure your path is correct. It may help to var_dump(FCPATH) so that you see where it is going. Just a note, if you are not trying to save this in your applications directory you won't be able to use FCPATH. You will have to write the full path yourself.
            – Colby Boren
            Nov 14 at 17:13










          • finally got it working $filename = 'Document.pdf'; $pdfFilePath = "/var/www/html/calsierra/uploads/docs/$filename"; $pdf->writeHTML($html, true, false, true, false, ''); $pdf->Output($pdfFilePath, 'F');
            – Aman
            Nov 14 at 17:47
















          $pdf->Output(FCPATH . 'home/cal_user/calsierra/uploads/docs/" . "Document.pdf', 'F'); exit();
          – Aman
          Nov 14 at 15:23




          $pdf->Output(FCPATH . 'home/cal_user/calsierra/uploads/docs/" . "Document.pdf', 'F'); exit();
          – Aman
          Nov 14 at 15:23












          I added like this but it just open the new window without saving the pdf
          – Aman
          Nov 14 at 15:24




          I added like this but it just open the new window without saving the pdf
          – Aman
          Nov 14 at 15:24












          and it gives no error
          – Aman
          Nov 14 at 15:27




          and it gives no error
          – Aman
          Nov 14 at 15:27












          Make sure your path is correct. It may help to var_dump(FCPATH) so that you see where it is going. Just a note, if you are not trying to save this in your applications directory you won't be able to use FCPATH. You will have to write the full path yourself.
          – Colby Boren
          Nov 14 at 17:13




          Make sure your path is correct. It may help to var_dump(FCPATH) so that you see where it is going. Just a note, if you are not trying to save this in your applications directory you won't be able to use FCPATH. You will have to write the full path yourself.
          – Colby Boren
          Nov 14 at 17:13












          finally got it working $filename = 'Document.pdf'; $pdfFilePath = "/var/www/html/calsierra/uploads/docs/$filename"; $pdf->writeHTML($html, true, false, true, false, ''); $pdf->Output($pdfFilePath, 'F');
          – Aman
          Nov 14 at 17:47





          finally got it working $filename = 'Document.pdf'; $pdfFilePath = "/var/www/html/calsierra/uploads/docs/$filename"; $pdf->writeHTML($html, true, false, true, false, ''); $pdf->Output($pdfFilePath, 'F');
          – Aman
          Nov 14 at 17:47


















           

          draft saved


          draft discarded















































           


          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53232712%2fnot-able-to-save-generated-pdf-on-my-remote-server%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Darth Vader #20

          How to how show current date and time by default on contact form 7 in WordPress without taking input from user in datetimepicker

          Ondo