using input file to display thumbnail

Posted on 2012-04-07
Last Modified: 2012-04-07
is it possible to display a thumbnail when the user selects a image?  

Question by:MK15
  • 4
  • 2
LVL 14

Expert Comment

ID: 37819111
Certainly.  How would you like to display the thumbnail?  What does your app look like?  Send some code and tell me what you want and I'll help you.
LVL 13

Expert Comment

by:Hugh McCurdy
ID: 37819903
I have two code examples, one in JavaScript and another in JQuery.  The javaScript one is a bit more complicated than it needs to be for a simple example but it works.  The JQuery one is simpler.

JavaScript --

JQuery --
LVL 14

Expert Comment

ID: 37819968
What I'm asking is:

Are you trying to have a single image like this:

[main image]

And, then have a bunch of thumbnails like this:


And, when a user clicks a thumbnail then the main image becomes an enlarged version of the thumbnail they clicked?

Basically, just tell me specifically what you're trying to do.
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.


Author Comment

ID: 37819974
ok sorry for the lack of information.

what i am trying todo is have a button(<input type='file' name ='select_image'/>), where the user can select an image to upload.  The selected image is then displayed in a thumbnail image holder '<img src="selected_image" alt="image" />'.  I want todo this before actually submitting the form.

Hope this is clearer.

LVL 14

Accepted Solution

EMB01 earned 500 total points
ID: 37819982
If you mean to select an image from their computer (from their local machine) and show it before it's actually uploaded from the server, this wouldn't be possible being as we can't show it in our web page without it first being placed on the server.  You could do an ajax upload and upload it as soon as they select it, then you could show it before submitting the form.

Author Comment

ID: 37819995
o ok, thats interesting, ill look into that.

thank you both for your help
LVL 14

Expert Comment

ID: 37820025
To help you out, check out  It's a great ajax uploader.

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Suggested Solutions

Introduction A frequently asked question goes something like this:  "I am running a long process in the background and I want to alert my client when the process finishes.  How can I send a message to the browser?"  Unfortunately, the short answer …
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
In this tutorial viewers will learn how add a full-size background image to a webpage using CSS3. Create a new HTML document with an internal stylesheet.: In CSS, define the html element to have a background image. Use a high resolution image.: In t…
In this tutorial viewers will learn how to code links for mobile sites that, once clicked, send a call or text to a specified number. For a telephone link (once clicked, calls a number), begin with a normal "<a href=" link tag. For the href, specify…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now