sadik7266 / jquery-multifile-plugin

Automatically exported from code.google.com/p/jquery-multifile-plugin
0 stars 0 forks source link

This is a small improvement of your great script form showing filesize when selecting a file. #163

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
After LINE 290 of jquery.MultiFile.js file I could add this simple code (or 
similar):
>>     var myForm = document.forms.MyFormId;
>>     var myControls = myForm.elements['MyFileInputName[]'];
>>     for (var i = (myControls.length-2); i >= 0; i--) {
>>         var MyFilSize = myControls[i].files[0].size;
>>         MyFilSize = Math.round((MyFilSize /(1024*1024))*100)/100;
>>         break;
>>     }
Then, a couple of lines after, could make --->this changes<---, or some similar:
>>     a = $('<span class="MultiFile-title"
>>         title="'+MultiFile.STRING.selected.
>>         replace('$file', v)+'">'+MultiFile.STRING.
>>         file.replace('$file', v.match(/[^\/\\]+$/gi)[0])+
>>         '---> ('+MyFilSize +'Mb)<---</span>'),
>>         b = $('<a class="MultiFile-remove" 
href="#'+MultiFile.wrapID+'">'+MultiFile.STRING.remove+'</a>');

Saludos!!
@sanxofon

Original issue reported on code.google.com by sanxo...@gmail.com on 4 Sep 2012 at 3:01

GoogleCodeExporter commented 8 years ago
You could clean the first pato to one line like this (or similar):
>> var MyFilSize = 
Math.round((document.forms.MyFormId.elements['MyFileInputName[]'][document.forms
.MyFormId.elements['MyFileInputName[]'].length-2].files[0].size/(1024*1024))*100
)/100;

@sanxofon

Original comment by sanxo...@gmail.com on 4 Sep 2012 at 3:09