asp.net - Link to image database -
i have following page:
@{ if (request["id"].isint()) { var imgid = request["id"].asint(); //data var db = database.open("amsdarquiteturaconnectionstring"); var image = db.querysingle("select * images [id] = @0", imgid); if (image.mimetype.startswith("image")) { response.addheader("content-disposition", "inline; filename=" + image.name); } else { response.addheader("content-disposition", "attachment; filename=" + image.name); } response.binarywrite((byte[])image.file); } }
i'm using plugin image zoom in, , need make link point image.
<a rel="images" title="myimage" href="projectimage?id=@img.id"></a>
the problem when click on link see meaningless code.
how make link point picture in database?
you need establish whether problem how using plugin, or razor code. request page directly, hard coding value imgid
make sure works properly. if have based database table , code on article bloke called mikesdotnetting, can simplify bit using webimage
helper:
@{ webimage image = null; int id = request["id"].asint(); var db = database.open("fileuploading"); var sql = "select * files fileid = @0"; var file = db.querysingle(sql, id); if(file != null){ image = new webimage((byte[])file.filecontent); } } @if(image != null){ @image.write(image.imageformat) }
if works, plugin might problem. try requesting image img
tag, src
pointing page generates image. it's odd approach uses anchors display images instead of img
tags.
or image itself. only image types supported browsers.
Comments
Post a Comment