www.webdeveloper.com
Results 1 to 14 of 14

Thread: <img src="... is not displaying image

  1. #1
    Join Date
    Jul 2014
    Posts
    3

    <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>
    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" />
    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

  2. #2
    Join Date
    Apr 2014
    Posts
    34
    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"/> - note the forward slash

    ----------------
    webdev_monkey
    www.online-webdev-tools.com

  3. #3
    Join Date
    Jul 2014
    Posts
    3
    Thanks for your reply but that did not work either here is the source :
    Code:
    Showing full path with photo name :<input name="path" value="/var/www/html/tmp/nancy.jpg" readonly><br>
    <IMG SRC="/var/www/html/tmp/nancy.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" />
    Any other suggestions or something that I can try.
    Thanks
    Terry

  4. #4
    Join Date
    Feb 2014
    Posts
    4
    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"/>

  5. #5
    Join Date
    Jul 2014
    Posts
    1
    Check whether the image source is correct or not...

  6. #6
    Join Date
    Apr 2014
    Posts
    34
    Hi,

    How did you get on with this, any luck?

    ----------------
    webdev_monkey
    www.online-webdev-tools.com

  7. #7
    check the folder again .There may be problem in resolution of the image .try another image .

  8. #8
    Join Date
    Nov 2013
    Location
    new york
    Posts
    66
    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.
    Looking for a best Web Design Training in New York? Briomatrix is the best institute.

  9. #9
    Join Date
    Mar 2011
    Posts
    1,141
    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:
    Code:
    <img src="/tmp/nancy.jpg" style="width:350px; height:500px; border:solid 10px #333;" alt=""/>
    Rick Trethewey
    Rainbo Design

  10. #10
    Join Date
    May 2014
    Posts
    936
    Quote Originally Posted by rtrethewey View Post
    Yes, the path is obviously incorrect
    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:

    Code:
    // assuming you're in a single quoted echo like a good little doobie
    echo '
    <form action="#" method="post">
    	<fieldset>
    		<label for="empid">Select Employee name for photo update:</label>
    		<select name="empid" id="empid">$options</select>
    		<br>
    		<label for="empPhotoPath">Enter full path with photo name:</label>
    		<input type="text" name="path" id="empPhotoPath" value="/tmp/', $filename, '" />
    		<br>     
    		<img
    			src="/tmp/', $filename, '"
    			alt="Employee Photo Preview"
    			width ="350" height="500"
    		/>
    		<br>  
    		<input type="submit" class="submit" value="UPDATE" />
    	</fieldset>
    </form>';
    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.
    Java is to JavaScript as Ham is to Hamburger.

  11. #11
    Join Date
    Aug 2014
    Posts
    2
    may be path is incorrect, you can find for mistakes or do this quick fix.
    simply open your online ftp manager , find the image you want to upload, and on properties or something, there must be an option of copting full path or copy embed src.
    now you know all the rest

  12. #12
    Join Date
    Aug 2014
    Location
    Sweden
    Posts
    6
    As well as the path, there's a space here
    <IMG SRC="/var/www/html/tmp/nancy.jpg" WIDTH ="350"
    right after width. I tried on my own and that ruins it for me. Try removing that

  13. #13
    check your image path is right or not.

  14. #14
    Join Date
    Jul 2014
    Location
    Dubai, United Arab Emirates
    Posts
    15
    Must add enctype="multipart/form-data" in the form like this, <form action="upload_file.php" method="post"
    enctype="multipart/form-data">

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles