4

I am trying to attach data and time with a filename but it is not working without any errors:

$date = date('Y/m/d H:i:s');
$pdf = $date.'order_sheet.pdf';

Through this code the file didn't become downloaded

5
  • what do you mean by attach? attaching to email? Or sending out to clients using Content-disposition? Or? Commented Apr 13, 2012 at 11:05
  • 3
    All you do is assign variables. What is the reason you expect this making a file downloadable? Commented Apr 13, 2012 at 11:05
  • Attach mean Concatenation with file name like pdf Commented Apr 13, 2012 at 11:06
  • also its not a good filename. Try something like date('Y_m_d_H_i_s'); Commented Apr 13, 2012 at 11:06
  • ^^^ what they said + plus I would suggest more friendly filenames such as date('Y-m-d-His') . '-order-sheet.pdf'; Commented Apr 13, 2012 at 11:07

3 Answers 3

4

You're using slashes and whitespaces in the filename, this isn't a good idea. Try to replace them with some other char, like so:

$date = date('Y_m_d-H-i-s');
Sign up to request clarification or add additional context in comments.

Comments

0

this will have special characters and space in the file name which is not allowed. That may be the cause. you should use timestamp instead of date & time.

Comments

0

you cannot use a / in a filename

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.