fopen(); “Remote host file access not accepted” on a local file?

前端 未结 7 775
-上瘾入骨i
-上瘾入骨i 2020-12-28 17:54

I am using the Tcpdf module and PHP to create dymanic PDF invoices from an ordering system.

The script should then save the invoice into a folder called \"invoices\"

7条回答
  •  囚心锁ツ
    2020-12-28 18:39

    After upgrading to the tcpdf 6.2.6 in vtiger 6.2 I've had the same problem, sending e-mail with pdf.

    So I have changed the file:

     libraries/tcpdf/include/tcpdf_static.php
    

    I have commented the code in fopenLocal() and changed the line

     fopen($_SERVER['DOCUMENT_ROOT'].$filename, $mode);
    

    see:

      /**
             * Wrapper to use fopen only with local files
             * @param filename (string) Name of the file to open
             * @param $mode (string) 
             * @return Returns a file pointer resource on success, or FALSE on error.  
             * @public static
             */
            public static function fopenLocal($filename, $mode) {
        //      if (strpos($filename, '://') === false) {
        //          $filename = 'file://'.$filename;
        //      } elseif (strpos($filename, 'file://') !== 0) {
        //          return false;
        //      }
                return fopen($_SERVER['DOCUMENT_ROOT'].$filename, $mode);
            }
    

    After changing this, it worked.

提交回复
热议问题