/    Sign up×
Community /Pin to ProfileBookmark

<img src="… is not displaying image

Hi,
I am trying to display image in the following form and its not showing the photo :

[code]
<form action=”” method=”post”>
Select Employee name for photo update :<select name=empid>$options</select><br>
Enter full path with photo name :<input name=”path” value=”$upload_dir/$filename”><br>
<IMG SRC=”$upload_dir/$filename” WIDTH =”350″ HEIGHT=”500″ ALIGN=”Right” BORDER =”10″ BORDERCOLOR=”#333″><br>
<input type=”submit” class=”tsc_c3b_large tsc_button tsc_c3b_blue tsc_c3b_input” name=”go” value=”UPDATE” />
</form>
[/code]

Here is the html source of the form :

[code]
Showing full path with photo name :<input name=”path” value=”/var/www/html/tmp/steven.jpg” readonly><br>
<IMG SRC=”/var/www/html/tmp/steven.jpg” WIDTH =”350″ HEIGHT=”500″ ALIGN=”Right” BORDER =”10″ BORDERCOLOR=”#333″><br>
<input type=”submit” class=”tsc_c3b_large tsc_button tsc_c3b_blue tsc_c3b_input” name=”go” value=”UPDATE” />
[/code]

if I copy /var/www/html/tmp/steven.jpg in my browser the image shows up fine and even with that path the update of the photo to the database goes through fine.

I gladly appreciate any help as I really don’t have a clue why this is happening.

Many thanks!
Terry

to post a comment
HTML

15 Comments(s)

Copy linkTweet thisAlerts:
@webdev_monkeyJul 17.2014 — It looks like your img tag isn't closed. Shouldn't it be:

<IMG SRC="/var/www/html/tmp/steven.jpg" WIDTH ="350" HEIGHT="500" ALIGN="Right" BORDER ="10" BORDERCOLOR="#333"[U][B][COLOR="#FF0000"]/[/COLOR][/B][/U]> - note the forward slash


----------------
webdev_monkey

[COLOR="#0000FF"][U]www.online-webdev-tools.com[/U][/COLOR]
Copy linkTweet thisAlerts:
@Terrykhatri531authorJul 17.2014 — Thanks for your reply but that did not work either here is the source :
<i>
</i>Showing full path with photo name :&lt;input name="path" value="/var/www/html/tmp/nancy.jpg" readonly&gt;&lt;br&gt;
&lt;IMG SRC="/var/www/html/tmp/nancy.jpg" WIDTH ="350" HEIGHT="500" ALIGN="Right" BORDER ="10" BORDERCOLOR="#333"/&gt;&lt;br&gt;
&lt;input type="submit" class="tsc_c3b_large tsc_button tsc_c3b_blue tsc_c3b_input" name="go" value="UPDATE" /&gt;


Any other suggestions or something that I can try.

Thanks

Terry
Copy linkTweet thisAlerts:
@swarananJul 18.2014 — try by adding ".."in front of path..


<IMG SRC="../var/www/html/tmp/nancy.jpg" WIDTH ="350" HEIGHT="500" ALIGN="Right" BORDER ="10" BORDERCOLOR="#333"/>
Copy linkTweet thisAlerts:
@qptopmJul 18.2014 — Check whether the image source is correct or not...
Copy linkTweet thisAlerts:
@YashaswiAgrawalJul 19.2014 — Hi all,

In the web-centric world of today, where user attention is growing shorter and shorter (in fact, it&#8217;s so

short that I&#8217;m not even sure whether you&#8217;re still reading this), I&#8217;m sure you&#8217;ve all wondered about what

design is most effective in capturing user attention. Targeted specifically to tackling this issue, I think this

book is perfect for you, someone who aims to make beautiful and effective designed websites. Find out

more about the book and preorder (for an extremely low price) here:

https://publishizer.com/design-to-delight/
Copy linkTweet thisAlerts:
@webdev_monkeyJul 21.2014 — Hi,

How did you get on with this, any luck?


----------------
webdev_monkey

[COLOR="#0000FF"][U]www.online-webdev-tools.com[/U][/COLOR]
Copy linkTweet thisAlerts:
@stevexJul 23.2014 — check the folder again .There may be problem in resolution of the image .try another image .
Copy linkTweet thisAlerts:
@arronmattwillsAug 02.2014 — It seems path is wrong here. Try by removing '/' or by adding '../' this may helps or see you have given space for the width attribute remove that space.

Make sure path should be correct.
Copy linkTweet thisAlerts:
@rtretheweyAug 02.2014 — Yes, the path is obviously incorrect. "/var/www/html/tmp/nancy.jpg" is the server directory path to the image. You need to change it to be relative to the domain root, which would be:
<i>
</i>&lt;img src="/tmp/nancy.jpg" style="width:350px; height:500px; border:solid 10px #333;" alt=""/&gt;
Copy linkTweet thisAlerts:
@deathshadowAug 03.2014 — Yes, the path is obviously incorrect[/QUOTE]
That's my take on it too -- well, along with all the other stuff that's just broken/gibberish HTML and bad coding practices -- like the static style in the markup, tags in caps like the OP is still writing HTML 3.2, attributes like BORDER that have no business on any website written after 1997 and attributes like BORDERCOLOR that never actually even existed...

Even the nesting order is junk -- since you can't have CDATA or inline-level tags as direct children of FORM.

I mean, no FIELDSET, no LABEL around your obvious text labels...

Then there's the broken image URL that is quite obviously a server path, not a web path. $uploadDir is quite obviously the local path, I SUSPECT that you should probably just have 'tmp/' there... or '/tmp/'... NOT that a temp directory makes a lot of sense in this case.

Though your double quotes while having $ values doesn't make a lot of sense either... and it's also not clear if you're using HTML or XHTML since you seem to have both closure methods in there.

Guessing wildly, but:

// assuming you're in a single quoted echo like a good little doobie
echo '
&lt;form action="#" method="post"&gt;
&lt;fieldset&gt;
&lt;label for="empid"&gt;Select Employee name for photo update:&lt;/label&gt;
&lt;select name="empid" id="empid"&gt;$options&lt;/select&gt;
&lt;br&gt;
&lt;label for="empPhotoPath"&gt;Enter full path with photo name:&lt;/label&gt;
&lt;input type="text" name="path" id="empPhotoPath" value="/tmp/', $filename, '" /&gt;
&lt;br&gt; <br/>
&lt;img
src="/tmp/', $filename, '"
alt="Employee Photo Preview"
width ="350" height="500"
/&gt;
&lt;br&gt; <br/>
&lt;input type="submit" class="submit" value="UPDATE" /&gt;
&lt;/fieldset&gt;
&lt;/form&gt;';


Probably would make more sense. Naturally, all that styling you were doing has no business in the markup and belongs in your stylesheet. Oh, and should that be text or file for that input? The "enter full path" part doesnae make a whole lot of sense.
Copy linkTweet thisAlerts:
@codegeeksAug 04.2014 — may be path is incorrect, you can find for mistakes or do this quick fix.

[B]simply open your online ftp [I]manager [/I], find the image you want to upload, and on [I]properties[/I] or something, there must be an option of[I] copting full path or copy embed src.[/I][/B]

now you know all the rest
Copy linkTweet thisAlerts:
@sebastianpierreAug 08.2014 — As well as the path, there's a space here <IMG SRC="/var/www/html/tmp/nancy.jpg" WIDTH ="350"[/QUOTE] right after width. I tried on my own and that ruins it for me. Try removing that ?
Copy linkTweet thisAlerts:
@puneetchauhanAug 08.2014 — check your image path is right or not.
Copy linkTweet thisAlerts:
@w3responsiveAug 10.2014 — Must add enctype="multipart/form-data" in the form like this, <form action="upload_file.php" method="post"

enctype="multipart/form-data">
Copy linkTweet thisAlerts:
@acoyyJul 31.2019 — @Terrykhatri531#1346469 try to combine with time() at the end of the image name.

Exp: <img src="image.jpg?<php echo time(); ?>">

this will make the cache also being refreshed, i guess?
×

Success!

Help @Terrykhatri531 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.22,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...