<style>
.thumb {
height: 75px;
border: 1px solid #000;
margin: 10px 5px 0 0;
}
</style>
<input name="fileAttach[]" type="file"
id="files1" /><br />
<output id="list1"></output>
<input
name="fileAttach[]" type="file" id="files2" /><br />
<output id="list2"></output>
<input name="fileAttach[]" type="file"
id="files3" /><br />
<output id="list3"></output>
<input name="fileAttach[]" type="file" id="files4" /><br />
<output id="list4"></output>
<input name="fileAttach[]" type="file" id="files4" /><br />
<output id="list5"></output>
<script>
function handleFileSelect(evt,list) {
alert(2);alert(evt);alert(list);
var files = evt.target.files;
for (var i = 0, f; f = files[i]; i++)
{
if (!f.type.match('image.*'))
{
continue;
};
var reader = new FileReader();
reader.onload = (function(theFile) {
return function(e) {
var span = document.createElement('span');
span.innerHTML = ['<img class="thumb" src="', e.target.result,'" title="', escape(theFile.name), '"/>'].join('');
document.getElementById(list).insertBefore(span, null);
};
})(f);
reader.readAsDataURL(f);
}
}
;
document.getElementById
('files1').addEventListener('change',
function(e){handleFileSelect(e,'list1')}, false);
document.getElementById('files2').addEventListener('change',
function(e){handleFileSelect(e,'list2')}, false);
document.getElementById('files3').addEventListener('change',
function(e){handleFileSelect(e,'list3')}, false);
document.getElementById('files4').addEventListener('change',
function(e){handleFileSelect(e,'list4')}, false);
document.getElementById('files5').addEventListener('change',
function(e){handleFileSelect(e,'list5')}, false);
</script>