Loading a picture from SD card to a webpage with W5100 and SDCARD

Please format your code...

Regarding what you want to do: When your browser hits against this simple server, the server merely spits out some HTML code. Part of that code is you tag, with a reference to your image (which I assume is on the SD card). Your browser then interprets the HTML to render it; when it gets to the tag, what it does then is why you aren't getting this to work - because it gets real complicated, really quickly.

Your browser at that point, reaches back out to the server (the link you have given in the tag is called a "relative link", by the way), and makes a second request for the image.

So - in order for your sketch to work - you need to modify your sketch to intercept this request, validate that it is an image request, then use the information gained to look up the image on the SD card and dump the image data back to the browser in the proper format. You are, in effect, needing to write a nearly full-blown web server application on the Arduino:

http://playground.arduino.cc/Code/WebServer

There is an example; specifically, the code at the bottom (by Alessandro Calzavara and Alberto Capponi) contains a function for outputting an image from the FLASH memory - you would need to extend this to read the request from the browser, interpret it (ie, get the filename/path), and use that to pull the data from the SD card. Your code will likely need to be lean and mean to fit everything you'll need in memory (ie, the SD card library, the SPI library, the ethernet stuff, etc).

The above may or may not be the best example - in fact, maybe somebody has already taken that library and made something similar to what you want, or has created their own that does what you need. Do some more research - you may find that you don't have to reinvent the wheel (or you may find that you do!)...

This isn't a trivial project - you may also want to research how to implement simple web servers for the PC, as well as how HTTP and such actually work in the context of the browser and web server. There's a lot of stuff going on under the hood when you browse the web; you only need to implement a small subset of it, but you still need to do it right (and in a very tiny memory space) to get it to work at all.

EDIT: Just noticed in your post (as I was posting) that you are using a Mega - so memory issues may not be as great a concern, depending on what your total application is for. Still, this only makes your memory footprint less of a headache - it doesn't make the problem simpler...