Reputation: 841
Hey my php/mysql/html people,
I have this variable that holds a path to an image and then insert it into a db (yes, I am using mysql_real_escape_string) which works perfectly.
$file_name = $_FILES["file"]["name"];
$path='images\ '. $file_name;
insert into...blah blah blah
The path is later pulled from the db and stored in said variable.
$path = $row['file_path'];
I am trying to display it with:
// the contents of $path in this case is: images\ cats.jpg
echo "<img src=" . $path . ">";
However the image breaks because the only thing that src pics up is: images\ and not the actualname+extension of the image. I know this probably has to do with the slashes, but I am a newbie and could use some help. Thanks in advance!
Upvotes: 0
Views: 138
Reputation: 493
Print $path variable & see the values.
echo $path;exit;
You will get value on web browser.
Copy the value displayed on browser & paste it in the URL, if you see the image, your saved path is correct, if not, you have gone wrong in specifying the relative path too the resource.
Upvotes: 0
Reputation: 8881
your
$path='images\ '. $file_name;
should be
$path='images\'. $file_name;
Upvotes: 1