Cross browser compatibility issues with image preview script.

	

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML1.0 Transitional//EN"



"http//www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 


<html xmlns="http://www.w3.org/1999/xhtml"> 


	<head> 

		<script type = "text/javascript" src="http://code.jquery.com/jquery-latest.js"> </script>


		<script type="text/javascript">

        		function readURL(input) {

            			if (input.files && input.files[0]) {

                			var reader = new FileReader();

                			reader.onload = function (e) {

                    				$('#blah').attr('src', e.target.result);

                			}

                			reader.readAsDataURL(input.files[0]);

            			}

        		}

    		</script>



	</head>


	<body>


		<form id="form1" runat="server" enctype="multipart/form-data">

        		<input type='file' onchange="readURL(this);" />

        		<img id="blah" src="#" width = "300px" max-height = "340px" alt="your image" />

    		</form>


	</body>



</html>
Sponsor our Newsletter | Privacy Policy | Terms of Service