无法将运行时生成的文件保存到目录


Unale to save runtime generated file to directory

我有一个表单。当用户提交表单时,我将数据存储在数据库中,并生成相同的pdf。这里我要做的是:

  • 下载PDF文件;
  • 将PDF文件保存在文件夹中。

下载PDF工作正常,但没有保存在文件夹中。

public function get_pdf() {
    $count = 1;
    for ($i = 0; $i < count($_POST['description']); $i++) {
        $table_data[] = array(
            'serial' => $count,
            'description' => $_POST['description'][$i],
            'unit' => $_POST['unit'][$i],
            'quantity' => $_POST['quantity'][$i],
            'rate' => $_POST['rate'][$i],
            'amount' => $_POST['amount'][$i]
        );
        $count++;
    }
    if (!empty($table_data)) {
        // loading pdf library //
        $this->load->library('cezpdf');
        // field names //
        $table_data_field = array(
            'serial' => 'S.No.',
            'description' => 'Work Description',
            'unit' => 'Unit',
            'quantity' => 'Quantity',
            'rate' => 'Rate',
            'amount' => 'Amount'
        );
        $this->cezpdf->ezTable($table_data, $table_data_field, 'Quotation', array('width' => 500, 'justification' => 'center'));
        ob_start();
        $this->cezpdf->ezStream();
        $data = ob_get_contents();
        ob_end_clean();
        // save the quotation file on client folder //
        move_uploaded_file('Quotation', FCPATH . '/quotation/' . $data);
        // force to download the file //
        $this->load->helper('download');
        force_download('Quotation.pdf', $data);
    }
}

请帮我一下。我使用CodeIgniter

首先,我认为您不应该使用move_uploaded_file,其次,您的文件名称包含PDF的内容,而不是文件名。