0
我有一種形式。當用戶提交表單時,我會將數據存儲在數據庫中並生成相同的pdf。這裏我想要做的是:不保存運行時生成的文件到目錄
- Download PDF file;
- 將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()我們正在使用,而文件通過形式上傳。我可以在這裏使用什麼?我對互聯網沒有任何想法或幫助。 – Ravi 2011-05-05 11:24:51
改用'rename'。 – 2011-05-05 11:35:30
問題解決了,而不是 'move_uploaded_file()以' 我用 'file_put_contents()' 這去... \t \t \t \t'//保存在客戶端文件夾中的文件的報價// ' \t \t'file_put_contents(FCPATH。'quotation'。DIRECTORY_SEPARATOR。'Quotation.pdf',$ data);' 謝謝大衛。 – Ravi 2011-05-05 11:45:18