File tree Expand file tree Collapse file tree 1 file changed +15
-1
lines changed
website/user_profile/templates Expand file tree Collapse file tree 1 file changed +15
-1
lines changed Original file line number Diff line number Diff line change 3232 </ div >
3333 < hr >
3434 < div >
35- {% render_field form.image class="form-control mt-4" style="background:white;" placeholder="Select An Image To Upload" %}
35+ {% render_field form.image class="form-control mt-4" style="background:white;" placeholder="Select An Image To Upload" onchange="ValidateSize(this)" type="file" %}
3636 </ div >
3737 < hr >
3838 </ table >
4949 </ div >
5050
5151</ body >
52+
53+ < script src ="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js "> </ script >
54+ < script >
55+ function ValidateSize ( file ) {
56+ var FileSize = file . files [ 0 ] . size / 1024 / 1024 ; // in MB
57+ if ( FileSize > 2 ) {
58+ alert ( 'File size exceeds 2 MB' ) ;
59+ $ ( file ) . val ( '' ) ;
60+ } else {
61+
62+ }
63+ }
64+ </ script >
65+
5266{% endblock %}
You can’t perform that action at this time.
0 commit comments