我有一些已经运行的代码,我已经将此代码转移到一个新的cpanel帐户,我遇到了类似的问题:

警告:fopen(downloads / liability / Ocean_Export_2015-09-03.pdf):无法打开流:1025行/home/hdxxdev/public_html/include/PDFConverter/fpdf.php中的权限被拒绝FPDF错误:无法创建输出文件:downloads / liability / Ocean_Export_2015-09-03.pdf

正在使用的文件夹:下载责任档案

我有趣的是它将许可从755更改为777,但它没有帮助 .

代码的想法是采用日期或日期范围,查询所有客户,将其添加到PDF,压缩和下载 .

PHP以防万一:

if($_SERVER['REQUEST_METHOD'] == 'POST'){
        require($_SERVER['DOCUMENT_ROOT'].'/include/PDFConverter/fpdf.php'); //file to turn PHP code into a PDF
        require_once('../include/PCLZip/pclzip.lib.php'); //file to turn PDF files into PDF
        require('../include/signature-to-image.php'); //code to convert signature code to an image.
        require('../include/resize.php'); //resize an image, sauce - http://www.white-hat-web-design.co.uk/blog/resizing-images-with-php/
        //Set timeout to 7.5 minutes
        ini_set('max_execution_time', 450);
        if($_POST['formIdentifier'] == "multiple_Date_Export"){
            $multiple_Date_Export = true;

            $thisDate = $_POST['fromDate'];
            $toDate = $_POST['toDate'];
            //These dates will be unmodified, will be used to name archive files
            $archiveFrom = $_POST['fromDate'];
            $archiveTo = $_POST['toDate'];
        }
        else{
            $thisDate = date("Y-m-d", strtotime($_POST['singleDate']));
            $toDate = $thisDate;
        }

        //While the from date is less than the to date
        while (strtotime($thisDate) <= strtotime($toDate)) {
            $query = mysqli_query($conn,"SELECT * FROM Customers WHERE travel_Date > '".$thisDate." 00:00:00' AND travel_Date < '".$thisDate." 23:59:59' ORDER BY l_Name");
            $indemResult = mysqli_query($conn,"SELECT * FROM Indemnity WHERE ind_Date <= '".$thisDate."' ORDER BY ind_Date desc");
            $indemRow = mysqli_fetch_array($indemResult);
            //echo "signature: ".$sigRow['signature'];
            /*turn PHP into PDF*/
            /*Turn JSON signature array into an image*/

            /*Create the PDF and configure*/
            $pdf = new PDF('P', 'mm', 'A4');

            $pdf->AliasNbPages();
            $pdf->SetMargins(0,5,0);
            $pdf->AddPage("P", "A4");
            $pdf->SetFont('Arial','',10);
            $pdf->cMargin = 10;
            //Display indemnity form and start page numbers
            $form = $indemRow['ind_Form'];
            $pdf->SetFont('Arial','',10);
            $text=$pdf->WriteHTML($form);

            //start keeping track of page numbers for table of contents
            $pdf->startPageNums(); 

            $pdf->MultiCell(0,0,$pdf->Write($text, ''));
            $pdf->AliasNbPages();


            //Code to display table of contents
            while($row = mysqli_fetch_array($query)){
                //Get name and page number, put into array
                $table_Of_Contents[$table_Of_Contents_Number] = $row['l_Name'].', '.$row['f_Name'];
                $table_Of_Contents_Number++;
            }

            //Move query back to first result.
            mysqli_data_seek($query, 0);

            while($row = mysqli_fetch_array($query)){
                //Make a new PDF page, add customer related details
                $pdf->SetMargins(0,25,0);
                $pdf->AddPage();

                //Add customer name into top left of page, setting the font to bold it
                $pdf->SetFont('Arial','B',10);
                $pdf->MultiCell(100,0,$pdf->WriteHTML('Passenger: '.$row['l_Name'].', '.$row['f_Name'], ''));
                $pdf->SetFont('Arial','',10);

                //Set X position to middle of page by moving it 100mm
                $pdf->SetX(100);

                //Add next lot of information to right of PDF
                $pdf->MultiCell(100,0,$pdf->WriteHTML('Travel Date: '.$row['travel_Date']));

                //Create a line break 5mm high
                $pdf->Ln('5');

                if( $row['child_1'] != "" || $row['child_2'] != ""){
                    $pdf->MultiCell(100,0,$pdf->WriteHTML('Minors: '.$row['child_1'].'. '.$row['child_2']));
                    $pdf->Ln('5');
                }
                if( $row['child_3'] != "" || $row['child_4'] != ""){
                    $pdf->MultiCell(100,0,$pdf->WriteHTML($row['child_3'].'. '.$row['child_4']));
                }
                $pdf->Ln('5');
                $pdf->MultiCell(100,0,$pdf->WriteHTML($row['address']));
                $pdf->SetX(100);

                if( $row['tour_ID'] != NULL || $row['tour_ID'] != "" ){


                    $tour_Query = mysqli_query($conn,"SELECT tour_Name FROM Tour WHERE tour_ID = '".$row['tour_ID']."'");
                    $row_Tour = mysqli_fetch_array($tour_Query);
                    $pdf->MultiCell(100,0,$pdf->WriteHTML('Tour Taken: '.$row_Tour['tour_Name']));
                }
                else{
                    $pdf->MultiCell(100,0,$pdf->WriteHTML('Tour Taken: - Nothing Entered -'));
                }

                $pdf->Ln('5');
                $pdf->MultiCell(100,0,$pdf->WriteHTML($row['suburb']));
                $pdf->Ln('5');
                $pdf->MultiCell(100,0,$pdf->WriteHTML($row['state'].', '.$row['country'].', '.$row['postcode']));

                $pdf->Ln('10');
                $pdf->MultiCell(100,0,$pdf->WriteHTML('Phone: '.$row['phone']));
                $pdf->SetX(100);
                $pdf->MultiCell(100,0,$pdf->WriteHTML('Email: '.$row['email']));

                //when done displaying content to page, add entry into TOC
                $pdf->TOC_Entry($row['l_Name'].', '.$row['f_Name'],''); 

                if( $row['signature'] != "" || $row['signature'] != NULL ){
                    //Display signature
                    $pdf->Ln('20');
                    $img = sigJsonToImage($row['signature'], array('imageSize'=>array(760, 390), 'drawMultiplier'=>1)); //turn into image
                    $imgLocation = '../tmp/';
                    imagepng($img, $imgLocation.'signature'.$row['customer_ID'].'.png');

                    //Call function to resize signature
                    $resize = new SimpleImage(); 
                    $resize->load('../tmp/signature'.$row['customer_ID'].'.png'); 
                    $resize->resize(398,255); 
                    $resize->save('../tmp/signature'.$row['customer_ID'].'.png');

                    //Insert Signature
                    $pdf->MultiCell(0,0,'I agree to the terms and conditions and confirm this is my signature:');
                    $pdf->Ln('10');
                    $pdf->SetX('85');
                    $pdf->Cell(10, 60, $pdf->Image('../tmp/signature'.$row['customer_ID'].'.png'),0,1,'R');
                }
            }//end while loop

            //Insert table of contents into page 1  
            $pdf->insertTOC(1);

            //If multiple dates were selected, we want to turn them into a zip file, and possible delete the files
            if($multiple_Date_Export){
                //$pdf->Output('../downloads/liability/Ocean_Rafting_Liability_Export_'.$thisDate.'.pdf', 'F');
                $pdf->Output('downloads/liability/Ocean_Rafting_Liability_Export_'.$thisDate.'.pdf', 'F');

            }
            else{
                $pdf->Output('Ocean_Rafting_Liability_Export_'.$thisDate.'.pdf', 'D');
            }
            $thisDate = date ("Y-m-d", strtotime("+1 day", strtotime($thisDate)));

        }//end while loop

        //Destroy image
        imagedestroy($img);

        //If multiple days are selected, we want to grab all files generated and zip them
        if($multiple_Date_Export){
            $dir = 'downloads/archive/';
            $archive = new PclZip($dir.'Ocean_Rafting_Liability_Export_'.$archiveFrom.'-'.$archiveTo.'.zip');
            $v_list = $archive->add('downloads/liability/',
                                    PCLZIP_OPT_REMOVE_ALL_PATH);
            if ($v_list == 0) {
                die("Error : ".$archive->errorInfo(true));
            }

            //Need to remove files from liability folder
            $files = glob('downloads/liability/*'); // get all file names
            foreach($files as $file){ // iterate files
              if(is_file($file))
                unlink($file); // delete file
            }

            //Force download of zip file through web browser
            $yourfile = $dir.'Ocean_Rafting_Liability_Export_'.$archiveFrom.'-'.$archiveTo.'.zip';
            $file_name = basename($yourfile);
            header("Content-Type: application/zip");
            header("Content-Disposition: attachment; filename=$file_name");
            header("Content-Length: " . filesize($yourfile));
            readfile($yourfile);
            //After user downloads file, remove archive
            if(is_file($yourfile)){
                unlink($yourfile);
            }
            exit;
        }

        //} //If form identifier