使用FPDF

时间:2018-05-31 12:50:11

标签: php fpdf

我已使用FPDF成功创建了PDF文档,但无法将其保存到服务器上的文件夹中。我能够将PDF文档输出到浏览器。

我还允许写入此文件夹的权限' fullSizeA4PdfPage':

drwxrwxrw-

我的PHP代码:

require('fpdf181/fpdf.php');

$pdf = new FPDF('P','pt','A4');
$pdf->AddPage();
$pdf -> Image($pathToImage, $centreX, $centreY, $imageWidth, $imageHeight);

// SAVE A4PDF FILE TO LOCAL DIR ('/fullSizeA4PdfPage')
$nameA4PDF = 'A4PdfPage.pdf';
$A4PDFPageFolder = 'fullSizeA4PdfPage';
$localPathA4PFD = $A4PDFPageFolder.'/'.$nameA4PDF;
$pdf -> Output('F', $localPathA4PFD);  // LINE 80 I have also tried $pdf -> Output($localPathA4PFD, 'F' );

我从浏览器收到以下错误:

  

警告:file_put_contents(fullSizeA4PdfPage / A4PdfPage.pdf):未能   open stream:没有这样的文件或目录   第1021行/var/www/html/labbook_aws/lab_server/fpdf181/fpdf.php

1 个答案:

答案 0 :(得分:0)

拥有

的权限
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;
[RequireComponent(typeof(Text))]
public class DebugShowUnderCursor : MonoBehaviour
{
    Text text;
    EventSystem eventSystem;
    List<RaycastResult> list;
    void Start()
    {
        eventSystem = EventSystem.current;
        text = GetComponent<Text>();
        text.raycastTarget=false;
    }

    public List<RaycastResult> RaycastMouse(){
         PointerEventData pointerData = new PointerEventData (EventSystem.current)   {  pointerId = -1, };
         pointerData.position = Input.mousePosition;
         List<RaycastResult> results = new List<RaycastResult>();
         EventSystem.current.RaycastAll(pointerData, results);
         return results;
     }
    void Update()
    {
        list= RaycastMouse();
        string objects="";
        foreach ( RaycastResult result in list)
            objects+=result.gameObject.name+"\n";
        text.text = objects;
    }
}

在与所有者不同或在同一组中的用户下运行的进程无法访问目录的内容(请注意缺少的最后drwxrwxrw- )。因此,如果您的脚本在与目录所有者不同的用户下运行,请尝试使用x而不是777的权限。

另请参阅this question以了解776位的含义。似乎即使x应该足以在目录中读取和写入文件,但如果没有rw文件的元数据也无法读取,那么某些功能可能无法打开文件一点都不。

相关问题