zoukankan      html  css  js  c++  java
  • 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);  } }

  • 相关阅读:
    MySQL基础(3):进阶用法
    MySQL基础(2):DDL语言
    MySQL基础(1):基本语法
    Linux中配置ftp传输
    Eclipse插件安装的三种方法
    C++中string,wstring,CString的基本概念和用法
    程序员的谈判技巧
    转:C++编程隐蔽错误:error C2533: 构造函数不能有返回类型
    CMake入门以及学习笔记
    程序员的学习方法
  • 原文地址:https://www.cnblogs.com/pengfeiwang/p/4372709.html
Copyright © 2011-2022 走看看