save a pdf filename with slash in root directory cakephp

914 Views Asked by At

I am working with cakephp 2.5 and trying to save a pdf file into root directory named Service_Invoices .

PDF File name is :

$pdf_file_name = 'ISE-00000104/17.pdf';

And the Root path :

$pdf_file_path = WWW_ROOT . 'files\Service_Invoices';

The problem is the slash in the file name. How to save this file with filename contain slash.

NB. The file name is a invoice id so it can not be changed.

1

There are 1 best solutions below

0
On

The content of $pdf_file_name is not a filename, but a file path. The filename is 17.pdf.

Several options here:

  • You can remove the slash and replace with another char, if you want to keep the original file path information.
  • You can create the folder ISE-00000104 within your target directory and save the 17.pdf in there to have the same structure.
  • You can remove the path information and just save 17.pdf to $pdf_file_path.

Filenames with a slash are not possible on Windows or Unix.