• dnn 添加图片


     public string fileUpload()         {             if (fuPhoto.PostedFile != null && fuPhoto.PostedFile.ContentLength > 0)             {                 int _ModuleID = (this.Parent.TemplateControl as View).ModuleId;

                    string ext = System.IO.Path.GetExtension(fuPhoto.PostedFile.FileName).ToLower();                 if (ext != ".jpg" && ext != ".jpeg" && ext != ".bmp" && ext != ".gif")                 {                     return "";                 }                 string filename = "photo" + DateTime.Now.ToString("yyyyMMddHHmmss") + ext;                 string path = "upload/" + _ModuleID + "/photo/" + UserId + "/";

                    var dnn_path =  DotNetNuke.Services.FileSystem.FolderManager.Instance.AddFolder(PortalId,path);

                    var dnn_file= DotNetNuke.Services.FileSystem.FileManager.Instance.AddFile(dnn_path, filename, fuPhoto.PostedFile.InputStream);

                    return dnn_file.FileId.ToString();             }             else             {                 //do some thing;                 return "";             }         }

    public static void UpdateProfilePhoto(UserInfo user, string photoPath) {  DotNetNuke.Services.FileSystem.IFolderInfo fi = DotNetNuke.Services.FileSystem.FolderManager.Instance.GetUserFolder(user);  DotNetNuke.Services.FileSystem.IFileInfo file;

     using (FileStream localFileStream = new FileStream(photoPath, FileMode.Open))  {  file = DotNetNuke.Services.FileSystem.FileManager.Instance.AddFile(fi, "profilepicture" + user.UserID.ToString() + ".jpg", localFileStream);  user.Profile["Photo"] = file.FileId;  UserController.UpdateUser(user.PortalID, user);  } }

  • 相关阅读:
    2019-2020-1 20191326《信息安全专业导论》第四周学习总结
    如何在大学里脱颖而出
    2019-2020-1 20191326 《信息安全专业导论》第三周学习总结
    2019-2020-1 20191326《信息安全专业导论》第二周学习总结
    师生关系
    Idea Terminal中配置git和maven命令
    bootstrapTable 设置行样式
    Jquery 遍历数组
    Java 截取字符串
    Tomcat 部署项目访问方式处理及部署多个项目
  • 原文地址:https://www.cnblogs.com/pengfeiwang/p/4372709.html
Copyright © 2020-2023  润新知