asp.net mvc - handling large file image upload -


on asp.net mvc 4 site have feature user can upload photo, via standard file uploader. photo gets saved in file table within sql server.

i have run in issue users uploading large photos in return means bandwidth being eaten when image being rendered.

what best way handle this? can restrict size of file being uploaded? or there way of reducing number of bytes being uploaded while maintaining quality?

refer this post maximumrequestlength config setting , way provide more friendly error

this question , answer may helpful

you can check size of file in javascript before uploading doesn't sent server if big (the code below check bigger 15mb):

if( math.floor( file.size / 1024 /1024 ) >= 15 ) {      alert( 'file size greater maximum allowed. please make sure file smaller 15 megabytes.'  );      return false; } 

alternatively, on server side can use webimage.resize() resize once file has been uploaded. won't bandwidth during upload, make subsequent downloads lot faster. making image smaller cause loss in quality, job, make sure choose option maintain aspect ratio prevent distortion.

as reducing bytes before uploading there isn't way know of in browser. provide separate client-side application resize files them before upload using webimage.resize method in app.


Comments

Popular posts from this blog

javascript - Count length of each class -

What design pattern is this code in Javascript? -

hadoop - Restrict secondarynamenode to be installed and run on any other node in the cluster -