使用PHP将文件保存到文件夹

时间:2015-06-09 14:59:14

标签: php dictionary fopen tcpdf

我尝试的几个例子

// Worked
fopen($OutputFolderPath."Text.pdf", "w");

// Didn't work
$pdf->Output($OutputFolderPath . $Mother->PatientTableRecord['Forename'] . ' ' . $Mother->PatientTableRecord['Surname']  . '_' . $Mother->PatientTableRecord['NHSID'] . ' ' . date('d_m_Y') . '.pdf','F');  // $OutputFolderPath . $Mother->PatientTableRecord['Forename'] . ' ' . $Mother->PatientTableRecord['Surname']  . ' ' . date('d_m_Y h_i_s', time()) . '.pdf','F'

// Works with no PDF content inside
fopen($OutputFolderPath . $Mother->PatientTableRecord['Forename'] . ' ' . $Mother->PatientTableRecord['Surname']  . '_' . $Mother->PatientTableRecord['NHSID'] . ' ' . date('d_m_Y') . '.pdf','F');  // $OutputFolderPath . $Mother->PatientTableRecord['Forename'] . ' ' . $Mother->PatientTableRecord['Surname']  . ' ' . date('d_m_Y h_i_s', time()) . '.pdf','w');

// Worked
$pdf->Output('C:/ISOSEC/PDFS/' . ReplaceWindowsFileNameSpecialCharacters($Mother->PatientTableRecord['Forename'] . ' ' . $Mother->PatientTableRecord['Surname']  . '_' . $Mother->PatientTableRecord['NHSID'] . ' ' . date('d_m_Y') . '.pdf'),'F');  // $OutputFolderPath . $Mother->PatientTableRecord['Forename'] . ' ' . $Mother->PatientTableRecord['Surname']  . ' ' . date('d_m_Y h_i_s', time()) . '.pdf','F'

我试图使用$OutputFolderPath

' $ OutputFolderPath'路径:

//MIA-Test/htdocs/SharedFolder/MIA - Digital Post Natal Records/

错误:

fopen(file:////MIA-Test/htdocs/SharedFolder/MIA - Digital Post Natal Records/Fiona Appleton_1946546288 09_06_2015.pdf): failed to open stream: No such file or directory

1 个答案:

答案 0 :(得分:1)

使用此:

$a = file_get_contents('Text.pdf');
file_put_contents('new_text.pdf', $a);   
相关问题