c# - How to show image in DotNetNuke custom module? -
i'm writing custom module upload image. after upload file custom folder. when loading image, image's address correctly doesn't show in image control.
how show image in dotnetnuke custom module?
//save picture code: fileuppic.postedfile.saveas(mappath("~/images/hotels/" + filename)); //load picture code: while (dr.read()) { imgpic.imageurl = mappath("~/images/hotels/") + dr["picture"].tostring(); } //my imagecontrol : <asp:image id="imgpic" runat="server" />
you're not using file system intended dnn. images should managed through dnn's dotnetnuke.services.filesystem namespace , you're writing lot of code don't need in order save images (try dnnfilepickeruploader control, handles upload , passes fileid). once have fileid persisted object, use load image:
private string getpath(int fileid) { stringbuilder sb = new stringbuilder("/portals/"); ifileinfo fi = filemanager.instance.getfile(fileid); sb.append(fi.portalid); sb.append("/"); sb.append(fi.relativepath); return sb.tostring(); }
Comments
Post a Comment