asp.net mvc - Using backload to store files in database -


i'am trying use backload (https://github.com/blackcity/backload) upload images mvc application building. supposed able store images in database had no luck finding example demonstrates features.

anyone had luck this?

thanks

i had similar requirement , didn't want use entityframework, how handled :

custom controller :

public async task<actionresult> uploadimage()     {         fileuploadhandler handler = new fileuploadhandler(request, this);          handler.storefilerequestfinished += handler_storefilerequestfinished;          actionresult result = await handler.handlerequestasync();          return result;     } 

event handler method :

void handler_storefilerequestfinished(object sender, storefilerequesteventargs e)     {         //i know expecting 1 file...         var file = e.param.filestatus.single();         //call service layer method insert image data         //you base64 encode stram here , insert straight in db         service.insertproductimage(             int.parse(e.param.customformvalues["productid"]),              file.filename,              file.fileurl,              server.mappath(new uri(file.fileurl).pathandquery),              int.parse(e.param.customformvalues["filetypeid"]),              int.parse(e.param.customformvalues["colourid"]),              current.user().userid         );     } 

javascript upload in view

$('#form_focusgraphic').fileupload({             url: "/product/uploadimage",             acceptfiletypes: /(jpg)|(jpeg)|(png)|(gif)$/i,             fileinput: $('input#focusgraphicinput'),             maxfilesize: 5000000, //5mb             formdata: [{ name: 'productid', value: '@model.productid' }, { name: 'filetypeid', value: '3' }, { name: 'colourid', value: '0' }, { name: 'uploadcontext', value: "3;0" }],             start: function (e, data) {                 $('img#focusimage').attr('src', '/content/img/largespinner.gif');             },             done: function (e, data) {                 var obj = jquery.parsejson(data.jqxhr.responsetext);                 $('img#focusgraphic').attr('src', obj.files[0].url);             }         }); 

so send request controller ( passing in specific custom params ) , attach custom event fileuploadhandler call custom handler on "storefilerequestfinished", pretty simple actually.


Comments

Popular posts from this blog

plot - Remove Objects from Legend When You Have Also Used Fit, Matlab -

java - Why does my date parsing return a weird date? -

Need help in packaging app using TideSDK on Windows -