I'm trying to show an pdf file stored local in the browser with this code:
<p><a href=<?php
$sql = "select title from tasks where taskPK='".$_SESSION['task']."'";
$res = $db->query($sql);
if (!$res) {
throw new Exception("Database Error [{$db->errno}] {$db->error}");
}
while($row = $res->fetch_assoc()){
$rad= $row['title'];
echo ("files/".$id."/".$rad.".pdf"); }?> > See PDF </a> </p>
This should go into the right folder and get the file and then show it. But my problem is that if the name of the file has an space for example "peter pan.pdf" Then it won't work. The URL is supposed to be localhost/upload/files/9/Peter%20Pan.pdf But that doesn't happen. The URL is localhost/upload/filer/9/Peter It stops when the space hits and the file doesn't show.
But if the filename is connected with a - like this: "Peter-Pan.pdf" it works. Then the URL becomes localhost/upload/filer/9/Peter-Pan.pdf And the PDF shows.
Whats the problem? Sorry if it is a bit messy.
$id is the user wich becomes 9 in the URL
The problem should be in here but i can't figuire it out:
echo ("files/".$id."/".$rad.".pdf"); }?> > See PDF </a> </p>