I have a form with an image upload field. When the user selects an image from the desktop, the preview box displays the image (before uploading occurs). My script works on Firefox and Chrome but it doesn’t work on Safari (Windows). Below is the code I have right now:
<!DOCTYPE html>
<html>
<head>
<title>Preview</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script>
function readURL(input) {
if (input.files && input.files[0]) {
var reader = new FileReader();
reader.onload = function (e) {
$('#preview').attr('src', e.target.result);
};
reader.readAsDataURL(input.files[0]);
}
}
</script>
</head>
<body>
<input type='file' onchange="readURL(this);" />
<img id="preview" src="" />
</body>
</html>
Is there a way to make it also work on Safari (Windows)?
Dave, thank you very much. I think I can use your suggestion. I have never worked with Ajax but since that you are saying it is possible, I will see what I can do.