Display image using absolute path
I am using uploadify to upload img to server at the time of upload i saved absolute path to the data base its like:
/var/www/html/workbench/photogallery/uploads/logo2.jpg
now I want to display the same in browser the following method does not work
<div id="photos">
<h3>Photo title</h3>
<P class="like"><a href="#">Like</a> </P>
<p class="date">date </p>
<p class="pclear" />
<div id="image">
<img src="<?php echo $result_set['path']; ?>" />
</div>
<p class="about">about image goes here</p>
</div>
above code doesn't work. when I edit the path manually to uploads/logo2.jpg it works perfectly
how can I resolve this problem?
php html
add a comment |
I am using uploadify to upload img to server at the time of upload i saved absolute path to the data base its like:
/var/www/html/workbench/photogallery/uploads/logo2.jpg
now I want to display the same in browser the following method does not work
<div id="photos">
<h3>Photo title</h3>
<P class="like"><a href="#">Like</a> </P>
<p class="date">date </p>
<p class="pclear" />
<div id="image">
<img src="<?php echo $result_set['path']; ?>" />
</div>
<p class="about">about image goes here</p>
</div>
above code doesn't work. when I edit the path manually to uploads/logo2.jpg it works perfectly
how can I resolve this problem?
php html
Your server and client machine should be the same, are they?
– Tooraj Jam
Jun 5 '12 at 14:12
Never ever post an absolute path to the client. It's a large security risk. Use a path relative to the hostname, or just a relative path.
– Bojangles
Jun 5 '12 at 14:13
1
ye same . I can access the image in browser directly . path like this file:///var/www/html/workbench/photogallery/uploads/logo2.jpg
– sudeep cv
Jun 5 '12 at 14:14
@Compiler: Well you can; but I very much doubt that every visitor of your page will have/var/www/html/workbench/photogallery/uploads/logo2.jpg
on their computer.
– Piskvor
Jun 5 '12 at 14:16
add a comment |
I am using uploadify to upload img to server at the time of upload i saved absolute path to the data base its like:
/var/www/html/workbench/photogallery/uploads/logo2.jpg
now I want to display the same in browser the following method does not work
<div id="photos">
<h3>Photo title</h3>
<P class="like"><a href="#">Like</a> </P>
<p class="date">date </p>
<p class="pclear" />
<div id="image">
<img src="<?php echo $result_set['path']; ?>" />
</div>
<p class="about">about image goes here</p>
</div>
above code doesn't work. when I edit the path manually to uploads/logo2.jpg it works perfectly
how can I resolve this problem?
php html
I am using uploadify to upload img to server at the time of upload i saved absolute path to the data base its like:
/var/www/html/workbench/photogallery/uploads/logo2.jpg
now I want to display the same in browser the following method does not work
<div id="photos">
<h3>Photo title</h3>
<P class="like"><a href="#">Like</a> </P>
<p class="date">date </p>
<p class="pclear" />
<div id="image">
<img src="<?php echo $result_set['path']; ?>" />
</div>
<p class="about">about image goes here</p>
</div>
above code doesn't work. when I edit the path manually to uploads/logo2.jpg it works perfectly
how can I resolve this problem?
php html
php html
edited Nov 23 '18 at 11:41
Poul Bak
5,46831232
5,46831232
asked Jun 5 '12 at 14:10
sudeep cvsudeep cv
50451533
50451533
Your server and client machine should be the same, are they?
– Tooraj Jam
Jun 5 '12 at 14:12
Never ever post an absolute path to the client. It's a large security risk. Use a path relative to the hostname, or just a relative path.
– Bojangles
Jun 5 '12 at 14:13
1
ye same . I can access the image in browser directly . path like this file:///var/www/html/workbench/photogallery/uploads/logo2.jpg
– sudeep cv
Jun 5 '12 at 14:14
@Compiler: Well you can; but I very much doubt that every visitor of your page will have/var/www/html/workbench/photogallery/uploads/logo2.jpg
on their computer.
– Piskvor
Jun 5 '12 at 14:16
add a comment |
Your server and client machine should be the same, are they?
– Tooraj Jam
Jun 5 '12 at 14:12
Never ever post an absolute path to the client. It's a large security risk. Use a path relative to the hostname, or just a relative path.
– Bojangles
Jun 5 '12 at 14:13
1
ye same . I can access the image in browser directly . path like this file:///var/www/html/workbench/photogallery/uploads/logo2.jpg
– sudeep cv
Jun 5 '12 at 14:14
@Compiler: Well you can; but I very much doubt that every visitor of your page will have/var/www/html/workbench/photogallery/uploads/logo2.jpg
on their computer.
– Piskvor
Jun 5 '12 at 14:16
Your server and client machine should be the same, are they?
– Tooraj Jam
Jun 5 '12 at 14:12
Your server and client machine should be the same, are they?
– Tooraj Jam
Jun 5 '12 at 14:12
Never ever post an absolute path to the client. It's a large security risk. Use a path relative to the hostname, or just a relative path.
– Bojangles
Jun 5 '12 at 14:13
Never ever post an absolute path to the client. It's a large security risk. Use a path relative to the hostname, or just a relative path.
– Bojangles
Jun 5 '12 at 14:13
1
1
ye same . I can access the image in browser directly . path like this file:///var/www/html/workbench/photogallery/uploads/logo2.jpg
– sudeep cv
Jun 5 '12 at 14:14
ye same . I can access the image in browser directly . path like this file:///var/www/html/workbench/photogallery/uploads/logo2.jpg
– sudeep cv
Jun 5 '12 at 14:14
@Compiler: Well you can; but I very much doubt that every visitor of your page will have
/var/www/html/workbench/photogallery/uploads/logo2.jpg
on their computer.– Piskvor
Jun 5 '12 at 14:16
@Compiler: Well you can; but I very much doubt that every visitor of your page will have
/var/www/html/workbench/photogallery/uploads/logo2.jpg
on their computer.– Piskvor
Jun 5 '12 at 14:16
add a comment |
3 Answers
3
active
oldest
votes
You need to use an url, not a path.
This:
/var/www/html/workbench/photogallery/uploads/logo2.jpg
is a physical path, the address on that server where the image is found. You need to use an url available for your visitors. I guess that you have a name mapped to that server (something like localhost or www.example.com).
From the structure I guess that your url would be something like
http://www.example.com/photogallery/uploads/logo2.jpg
where www.example.com is the base url you are using to get to that application
add a comment |
Try this:
<img src="/photogallery/uploads/<?php echo basename($result_set['path']) ?>" />
add a comment |
Try this it works for me and keeps the location of the images hidden from the browser.
<img src='fake.php' style='max-width:90px;'/>
Create a file called fake.php as follows
<?php
$thePic = "/var/www/html/workbench/photogallery/uploads/logo2.jpg";
$image = imagecreatefromjpeg($thePic);
// Output image and free up the memory
header("Content-type: image/jpeg");
imagejpeg($image);
imagedestroy($image);
?>
You can adjust the code in the fake.php file to retrieve the location of $thePic from posted data or database, etc.
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f10898932%2fdisplay-image-using-absolute-path%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
You need to use an url, not a path.
This:
/var/www/html/workbench/photogallery/uploads/logo2.jpg
is a physical path, the address on that server where the image is found. You need to use an url available for your visitors. I guess that you have a name mapped to that server (something like localhost or www.example.com).
From the structure I guess that your url would be something like
http://www.example.com/photogallery/uploads/logo2.jpg
where www.example.com is the base url you are using to get to that application
add a comment |
You need to use an url, not a path.
This:
/var/www/html/workbench/photogallery/uploads/logo2.jpg
is a physical path, the address on that server where the image is found. You need to use an url available for your visitors. I guess that you have a name mapped to that server (something like localhost or www.example.com).
From the structure I guess that your url would be something like
http://www.example.com/photogallery/uploads/logo2.jpg
where www.example.com is the base url you are using to get to that application
add a comment |
You need to use an url, not a path.
This:
/var/www/html/workbench/photogallery/uploads/logo2.jpg
is a physical path, the address on that server where the image is found. You need to use an url available for your visitors. I guess that you have a name mapped to that server (something like localhost or www.example.com).
From the structure I guess that your url would be something like
http://www.example.com/photogallery/uploads/logo2.jpg
where www.example.com is the base url you are using to get to that application
You need to use an url, not a path.
This:
/var/www/html/workbench/photogallery/uploads/logo2.jpg
is a physical path, the address on that server where the image is found. You need to use an url available for your visitors. I guess that you have a name mapped to that server (something like localhost or www.example.com).
From the structure I guess that your url would be something like
http://www.example.com/photogallery/uploads/logo2.jpg
where www.example.com is the base url you are using to get to that application
edited May 30 '13 at 8:20
answered Jun 5 '12 at 14:13
mishumishu
4,68611734
4,68611734
add a comment |
add a comment |
Try this:
<img src="/photogallery/uploads/<?php echo basename($result_set['path']) ?>" />
add a comment |
Try this:
<img src="/photogallery/uploads/<?php echo basename($result_set['path']) ?>" />
add a comment |
Try this:
<img src="/photogallery/uploads/<?php echo basename($result_set['path']) ?>" />
Try this:
<img src="/photogallery/uploads/<?php echo basename($result_set['path']) ?>" />
answered Jun 5 '12 at 14:14
flowfreeflowfree
12.8k93662
12.8k93662
add a comment |
add a comment |
Try this it works for me and keeps the location of the images hidden from the browser.
<img src='fake.php' style='max-width:90px;'/>
Create a file called fake.php as follows
<?php
$thePic = "/var/www/html/workbench/photogallery/uploads/logo2.jpg";
$image = imagecreatefromjpeg($thePic);
// Output image and free up the memory
header("Content-type: image/jpeg");
imagejpeg($image);
imagedestroy($image);
?>
You can adjust the code in the fake.php file to retrieve the location of $thePic from posted data or database, etc.
add a comment |
Try this it works for me and keeps the location of the images hidden from the browser.
<img src='fake.php' style='max-width:90px;'/>
Create a file called fake.php as follows
<?php
$thePic = "/var/www/html/workbench/photogallery/uploads/logo2.jpg";
$image = imagecreatefromjpeg($thePic);
// Output image and free up the memory
header("Content-type: image/jpeg");
imagejpeg($image);
imagedestroy($image);
?>
You can adjust the code in the fake.php file to retrieve the location of $thePic from posted data or database, etc.
add a comment |
Try this it works for me and keeps the location of the images hidden from the browser.
<img src='fake.php' style='max-width:90px;'/>
Create a file called fake.php as follows
<?php
$thePic = "/var/www/html/workbench/photogallery/uploads/logo2.jpg";
$image = imagecreatefromjpeg($thePic);
// Output image and free up the memory
header("Content-type: image/jpeg");
imagejpeg($image);
imagedestroy($image);
?>
You can adjust the code in the fake.php file to retrieve the location of $thePic from posted data or database, etc.
Try this it works for me and keeps the location of the images hidden from the browser.
<img src='fake.php' style='max-width:90px;'/>
Create a file called fake.php as follows
<?php
$thePic = "/var/www/html/workbench/photogallery/uploads/logo2.jpg";
$image = imagecreatefromjpeg($thePic);
// Output image and free up the memory
header("Content-type: image/jpeg");
imagejpeg($image);
imagedestroy($image);
?>
You can adjust the code in the fake.php file to retrieve the location of $thePic from posted data or database, etc.
answered Nov 20 '16 at 9:12
user3639921user3639921
11
11
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f10898932%2fdisplay-image-using-absolute-path%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Your server and client machine should be the same, are they?
– Tooraj Jam
Jun 5 '12 at 14:12
Never ever post an absolute path to the client. It's a large security risk. Use a path relative to the hostname, or just a relative path.
– Bojangles
Jun 5 '12 at 14:13
1
ye same . I can access the image in browser directly . path like this file:///var/www/html/workbench/photogallery/uploads/logo2.jpg
– sudeep cv
Jun 5 '12 at 14:14
@Compiler: Well you can; but I very much doubt that every visitor of your page will have
/var/www/html/workbench/photogallery/uploads/logo2.jpg
on their computer.– Piskvor
Jun 5 '12 at 14:16