Getting the Uniform Resource Locator right

Please, could you help me with this:

My code works perfectly well
  $pdfcode = $pdf->output();
  $dir = 'dokument';
  //save the file
  if (!file_exists($dir))    {   mkdir ($dir,0777);  }
  $fname = tempnam($dir.'/','pdftest').'.pdf';
  $fp = fopen($fname,'w');

until I create a url for a link:

echo '<html>
<a href="'.$fname.'">click here</a>.
The $fname comes out in format like
/customers/4/8/3/, where  /customers/4/8/3/ is the absolute address for this server.
The url becomes which the browser doesn't understand.

Could you, please, help me create a working url.
Lennart EricsonAmateurAsked:
Who is Participating?
Ray PaseurConnect With a Mentor Commented:
I doubt if you can indict the IE browser completely.  Good coding practices will result in programming that works cross-browsers.

If $fname has several levels of directories, you might want to use basename() to retrieve the things you want to keep.

It is the same as end(explode(DIRECTORY_SEPARATOR, $fname));
Ray PaseurCommented:
Probably you want the URL to be something like this, maybe? 

If so you might try using $_SERVER["HTTP_HOST"] . DIRECTORY_SEPARATOR . $dir . DIRECTORY_SEPARATOR . 'pdftesteMRNMS.pdf'
Lennart EricsonAmateurAuthor Commented:
My problem is this:
The variable "$fname" is output "/customers/4/8/3/" and I would like to have it just "pdftesteMRNMS.pdf". I. e. I'd like to strip off  "/customers/4/8/3/"
How can that be achieved?
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Lennart EricsonAmateurAuthor Commented:
This was IE browser problem. Solution was simple: Close browser and restart.
Lennart EricsonAmateurAuthor Commented:
Your answeer to my question is correct and accepted. Thank you.
Ray PaseurCommented:
Glad to help -- thanks for the points and best of luck with your project! ~Ray
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.