javascript - How do I make the thumbnails appear below the "Add File" button? -
i have code show thumbnail preview of file user chooses upload. however, want more this:
i trying accomplish few things thumbnail part:
- to show thumbnail previews below "add file" button
- to show image smaller image image, file preset image of file, , video thumbnail video play symbol on (see link above examples)
to set maximum of 5 possible files uploaded.
<script type="text/javascript"> $(function() { $("#uploadfile").on("change", function() { var files = !!this.files ? this.files : []; if (!files.length || !window.filereader) return; // no file selected, or no filereader support if (/^image/.test( files[0].type)){ // image file var reader = new filereader(); // instance of filereader reader.readasdataurl(files[0]); // read local file reader.onloadend = function(){ // set image data background of div $("#imagepreview").css("background-image", "url("+this.result+")"); } } }); });
1) show thumbnail previews below "add file" button
move tag id="imagepreview" bellow file input
2) show image smaller image image, file preset image of file, , video thumbnail video play symbol on (see link above examples)
set css #imagepreview ex: #imagepreview { width: 100px; height: 100px; }
3) have no upload functionality provided, ... no more 1 field , preview in code ... how can you? - add counter global var , check ... when reaches 5 ... hide file input
Comments
Post a Comment