File Output

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
icesolid
Forum Regular
Posts: 502
Joined: Mon May 06, 2002 9:36 pm
Location: Buffalo, NY

File Output

Post by icesolid »

I am currently using HTML2PDF to generate dynamic PDFs on the fly.

Everything works smooth as far generating the PDF goes.

The only problem I am having is when I want to output that PDF file name it cannot have any spaces in the file name. So like if I needed to have "Joe Smith; CPP45746545" as the file name it would not work. But if I used "Joe_Smith_CPP45746545" the file would output successfully.

Here is the output code that I am using:

Code: Select all

<?php
$filename = $row["name_of_insured"] . "; " . $row["policy_number"];

$pdf->Output("$filename.pdf", "I");
?>
That output generates a unusable file. Not a valid PDF file because of the spaces. I am wondering why this won't work with spaces because you can put files on your server like "Joe Smith.mp3" and the file is accessible.

The "I" means open the file and if I replaced that "I" with a "D" it would mean download the file. I don't think that has anything to do with my problem here. Either way it does not work.
cent
Forum Newbie
Posts: 16
Joined: Wed Nov 16, 2005 2:23 pm

Post by cent »

try putting %20 instead of spaces. that should put spaces where you want them.
Post Reply