maddy maddy - 1 year ago 97
jQuery Question

Jquery Preview image before upload

i need to preview image before upload i tried following code but it's not doing anything.

<form name=”user_profile” id=”user_profile” action=”” method=”POST” enctype=”multipart/form-data” >

<div class=”profile”>
<img class=”list_prev” id=”user_old” src=”add path her for preview image from folder”>

<input type=”file” id=”user_image” class=”image ” name=”user_image” value=”” onchange=”preview_profile_image(this)” />



This is my script..

<script type=”text/javascript”>

function preview_profile_image(input) {
if (input.files && input.files[0]) {
var filerdr = new FileReader();

filerdr.onload = function(e) {



anyone please help me what's wrong.

Answer Source

Use src instead of id at line jQuery(‘.list_prev’).attr(‘src’,;

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download