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

Saving File to Folder using PHP

我试过的几个例子

// 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

使用这个:

$a = file_get_contents('Text.pdf');
file_put_contents('new_text.pdf', $a);