Skip to content Skip to sidebar Skip to footer

Preview Images Before It Is Uploaded For More Than One Image

I want to be able to preview images in form before they are uploaded and I have customized like I need to replace rectangle with plus inside with an imag

Solution 1:

Yes, you can display preview of image before uploading form

Try this Example

Thanks.


Updating the answer:

Try this JSFiddle example

HTML

<formname=""method="post"action="#"class="feedback-form-1"><fieldset><divclass="input-file-row-1"><divclass="upload-file-container"><imgid="preview_image"src="#"alt="" /><divclass="upload-file-container-text"><divclass = 'one_opacity_0'><inputtype="file"id="patient_pic"label = "add" /></div><span> Add Photo </span></div></div></div></fieldset></form>

JQuery:

functionreadURL(input, target) {
    if (input.files && input.files[0]) {
        var reader = newFileReader();
        var image_target = $(target);
        reader.onload = function (e) {
            image_target.attr('src', e.target.result).show();
        };
        reader.readAsDataURL(input.files[0]);
     }
 }

 $("#patient_pic").live("change",function(){
    readURL(this, "#preview_image")
 });

CSS:

.input-file-row-1:after {
    content: ".";
    display: block;
    clear: both;
    visibility: hidden;
    line-height: 0;
    height: 0;
}

.input-file-row-1{
    display: inline-block;
    margin-top: 25px;
    position: relative;
}

#preview_image {
  display: none;
  width: 90px;
  height: 90px;
  margin: 2px0px0px5px;
  border-radius: 10px;
}

.upload-file-container { 
    position: relative; 
    width: 100px; 
    height: 137px; 
    overflow: hidden;   
    background: url(http://i.imgur.com/AeUEdJb.png) top center no-repeat;
    float: left;
    margin-left: 23px;
} 

.upload-file-container-text{
    font-family: Arial, sans-serif;
    font-size: 12px;
    color: #719d2b;
    line-height: 17px;
    text-align: center;
    display: block;
    position: absolute; 
    left: 0; 
    bottom: 0; 
    width: 100px; 
    height: 35px;
}

.upload-file-container-text > span{
    border-bottom: 1px solid #719d2b;
    cursor: pointer;
}

.one_opacity_0 {
  opacity: 0;
  height: 0;
  width: 1px;
  float: left;
}

Post a Comment for "Preview Images Before It Is Uploaded For More Than One Image"