图片保存名为gomeihua mongotemplate 保存是哪个app

POCO摄影手机版
新导航介绍,
当前位置: &
切换模式:
邻家大男孩,虽然没有帅气的外表,但是阳光开朗乐观却能够时刻感染你!
如果喜欢这张图片,可以收录起来。
闪念,从一张图出发!收录此图与大家分享
版权声明:请尊重原创作品,转载时标明文章原始出处及作者信息
分享此作品 (0)
同时转帖到我的微博
推荐此作品
同时投上一票
近期大奖活动
| 按键盘←看作者的上一组作品,按键盘→键看作者的下一组作品
微信扫一扫,分享作品
帮助 & 服务
内容合作、出版发行合作联系方式:020-  
Copyright&
POCO CO.,LTD.
广告投放联系方式:华东:021-
华南:020-
华北:010-
POCO网违法和不良信息举报电话:
举报邮箱:C#实现图片上传(PC端和APP)保存及 跨域上传说明
作者:深入学习ing
字体:[ ] 类型:转载 时间:
这篇文章主要介绍了C#实现图片上传(PC端和APP)保存及 跨域上传说明的相关资料,非常不错,具有参考借鉴价值,需要的朋友可以参考下
1-页面--multiple是控制单张还是多张图片上传
&input id="BusRoute" type="file" class="btn btn-default btn-lg" style="height:34padding-top:5padding-bottom:5" multiple /&
2-后台获取图片文件:
HttpFileCollection pcFileColl = HttpContext.Current.Request.F
3-保存示例:
#region 创建目录
//完整存储路径
string completeUrl = "";
//相对等级路径
string relativeUrl = "";
//string saveTempPath = "~/Resources/Pic";
//string picUploadPath = HttpContext.Current.Server.MapPath(saveTempPath);
//添加根目录
completeUrl = @"\\10.0.8.52\YuanXinFiles\Office\"; ;
//添加一级目录
string relativeOneUrl = DateTime.Now.Year.ToString();
completeUrl += "\\" + relativeOneU
relativeUrl += "\\" + relativeOneU
if (!Directory.Exists(completeUrl))
Directory.CreateDirectory(completeUrl);
//添加二级目录
string relativeTwoUrl = DateTime.Now.Month.ToString();
completeUrl += "\\" + relativeTwoU
relativeUrl += "\\" + relativeTwoU
if (!Directory.Exists(completeUrl))
Directory.CreateDirectory(completeUrl);
#endregion
HttpFileCollection picColl = picModel.PcFileC
for (var i = 0; i & picColl.C i++)
HttpPostedFile file = picColl[i];
//保存图片
//保存至指定目录
file.SaveAs(completeUrl + "\\" + fileName);
前端页面长什么样不管了,后台拿到的是base64的字符串集合.
1-保存示例:
#region 创建目录
//完整存储路径
string completeUrl = "";
//相对等级路径
string relativeUrl = "";
//string saveTempPath = "~/Resources/Pic";
//string picUploadPath = HttpContext.Current.Server.MapPath(saveTempPath);
//添加根目录
completeUrl = @"\\10.0.8.52\YuanXinFiles\Office\"; ;
//添加一级目录
string relativeOneUrl = DateTime.Now.Year.ToString();
completeUrl += "\\" + relativeOneU
relativeUrl += "\\" + relativeOneU
if (!Directory.Exists(completeUrl))
Directory.CreateDirectory(completeUrl);
//添加二级目录
string relativeTwoUrl = DateTime.Now.Month.ToString();
completeUrl += "\\" + relativeTwoU
relativeUrl += "\\" + relativeTwoU
if (!Directory.Exists(completeUrl))
Directory.CreateDirectory(completeUrl);
#endregion
byte[] bytes = Convert.FromBase64String(strPic.picCode);
MemoryStream memStream = new MemoryStream(bytes);
BinaryFormatter binFormatter = new BinaryFormatter();
System.Drawing.Bitmap map = new Bitmap(memStream);
Image image = (Image)
string imageName = Guid.NewGuid().ToString("N");
//保存图片
image.Save(completeUrl + "\\" + imageName + "." + strPic.picType); //保存图片
C-跨域保存问题:
跨域的常见场景如下图所示:我们通过电脑的网络影射,连接到所需要的目录,这里添加上拥有权限的人员账号即可访问目标文件夹,那么使用C#代码如何获得访问权限呢?
要获取以上访问权限,需要引用一个类和添加一些简单代码:
1-访问代码:
/// &summary&
/// 通过指定用户执行上次图片操作
/// &/summary&
/// &param name="uploadAction"&&/param&
public void UploadFileByUser(Action uploadAction)
//参考类:D:\SourceCode\MCSFramework\02.Develop\MobileWebApp\YuanXin\Services\FileUploadService\Controllers\UploadController.cs
//无法通过权限认证--只能通过外网访问
var ip = "10.0.8.52";
var domain = "sinooceanland";
var username = ConfigurationManager.AppSettings["uploadUserName"].ToString(); //配置的用户名
var pwd = ConfigurationManager.AppSettings["uploadPassword"].ToString(); //配置的密码
var root = ConfigurationManager.AppSettings["uploadRootPath"].ToString(); //配置的文件根路径
using (NetworkShareAccesser.Access(ip, domain, username, pwd)) //建立连接
uploadAction(); //图片保存代码
catch (System.Exception e)
2-必须类:
public class NetworkShareAccesser : IDisposable
private string _remoteUncN
private string _remoteComputerN
public string RemoteComputerName
return this._remoteComputerN
this._remoteComputerName =
this._remoteUncName = @"\\" + this._remoteComputerN
public string UserName
public string Password
#region Consts
private const int RESOURCE_CONNECTED = 0x;
private const int RESOURCE_GLOBALNET = 0x;
private const int RESOURCE_REMEMBERED = 0x;
private const int RESOURCETYPE_ANY = 0x;
private const int RESOURCETYPE_DISK = 0x;
private const int RESOURCETYPE_PRINT = 0x;
private const int RESOURCEDISPLAYTYPE_GENERIC = 0x;
private const int RESOURCEDISPLAYTYPE_DOMAIN = 0x;
private const int RESOURCEDISPLAYTYPE_SERVER = 0x;
private const int RESOURCEDISPLAYTYPE_SHARE = 0x;
private const int RESOURCEDISPLAYTYPE_FILE = 0x;
private const int RESOURCEDISPLAYTYPE_GROUP = 0x;
private const int RESOURCEUSAGE_CONNECTABLE = 0x;
private const int RESOURCEUSAGE_CONTAINER = 0x;
private const int CONNECT_INTERACTIVE = 0x;
private const int CONNECT_PROMPT = 0x;
private const int CONNECT_REDIRECT = 0x;
private const int CONNECT_UPDATE_PROFILE = 0x;
private const int CONNECT_COMMANDLINE = 0x;
private const int CONNECT_CMD_SAVECRED = 0x;
private const int CONNECT_LOCALDRIVE = 0x;
#endregion
#region Errors
private const int NO_ERROR = 0;
private const int ERROR_ACCESS_DENIED = 5;
private const int ERROR_ALREADY_ASSIGNED = 85;
private const int ERROR_BAD_DEVICE = 1200;
private const int ERROR_BAD_NET_NAME = 67;
private const int ERROR_BAD_PROVIDER = 1204;
private const int ERROR_CANCELLED = 1223;
private const int ERROR_EXTENDED_ERROR = 1208;
private const int ERROR_INVALID_ADDRESS = 487;
private const int ERROR_INVALID_PARAMETER = 87;
private const int ERROR_INVALID_PASSWORD = 1216;
private const int ERROR_MORE_DATA = 234;
private const int ERROR_NO_MORE_ITEMS = 259;
private const int ERROR_NO_NET_OR_BAD_PATH = 1203;
private const int ERROR_NO_NETWORK = 1222;
private const int ERROR_BAD_PROFILE = 1206;
private const int ERROR_CANNOT_OPEN_PROFILE = 1205;
private const int ERROR_DEVICE_IN_USE = 2404;
private const int ERROR_NOT_CONNECTED = 2250;
private const int ERROR_OPEN_FILES = 2401;
#endregion
#region PInvoke Signatures
[DllImport("Mpr.dll")]
private static extern int WNetUseConnection(
IntPtr hwndOwner,
NETRESOURCE lpNetResource,
string lpPassword,
string lpUserID,
int dwFlags,
string lpAccessName,
string lpBufferSize,
string lpResult
[DllImport("Mpr.dll")]
private static extern int WNetCancelConnection2(
string lpName,
int dwFlags,
bool fForce
[StructLayout(LayoutKind.Sequential)]
private class NETRESOURCE
public int dwScope = 0;
public int dwType = 0;
public int dwDisplayType = 0;
public int dwUsage = 0;
public string lpLocalName = "";
public string lpRemoteName = "";
public string lpComment = "";
public string lpProvider = "";
#endregion
/// &summary&
/// Creates a NetworkShareAccesser for the given computer name. The user will be promted to enter credentials
/// &/summary&
/// &param name="remoteComputerName"&&/param&
/// &returns&&/returns&
public static NetworkShareAccesser Access(string remoteComputerName)
return new NetworkShareAccesser(remoteComputerName);
/// &summary&
/// Creates a NetworkShareAccesser for the given computer name using the given domain/computer name, username and password
/// &/summary&
/// &param name="remoteComputerName"&&/param&
/// &param name="domainOrComuterName"&&/param&
/// &param name="userName"&&/param&
/// &param name="password"&&/param&
public static NetworkShareAccesser Access(string remoteComputerName, string domainOrComuterName, string userName, string password)
return new NetworkShareAccesser(remoteComputerName,
domainOrComuterName + @"\" + userName,
password);
/// &summary&
/// Creates a NetworkShareAccesser for the given computer name using the given username (format: domainOrComputername\Username) and password
/// &/summary&
/// &param name="remoteComputerName"&&/param&
/// &param name="userName"&&/param&
/// &param name="password"&&/param&
public static NetworkShareAccesser Access(string remoteComputerName, string userName, string password)
return new NetworkShareAccesser(remoteComputerName,
password);
private NetworkShareAccesser(string remoteComputerName)
RemoteComputerName = remoteComputerN
this.ConnectToShare(this._remoteUncName, null, null, true);
private NetworkShareAccesser(string remoteComputerName, string userName, string password)
RemoteComputerName = remoteComputerN
UserName = userN
Password =
this.ConnectToShare(this._remoteUncName, this.UserName, this.Password, false);
private void ConnectToShare(string remoteUnc, string username, string password, bool promptUser)
NETRESOURCE nr = new NETRESOURCE
dwType = RESOURCETYPE_DISK,
lpRemoteName = remoteUnc
if (promptUser)
result = WNetUseConnection(IntPtr.Zero, nr, "", "", CONNECT_INTERACTIVE | CONNECT_PROMPT, null, null, null);
result = WNetUseConnection(IntPtr.Zero, nr, password, username, 0, null, null, null);
if (result != NO_ERROR)
throw new Win32Exception(result);
private void DisconnectFromShare(string remoteUnc)
int result = WNetCancelConnection2(remoteUnc, CONNECT_UPDATE_PROFILE, false);
if (result != NO_ERROR)
throw new Win32Exception(result);
/// &summary&
/// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
/// &/summary&
/// &filterpriority&2&/filterpriority&
public void Dispose()
this.DisconnectFromShare(this._remoteUncName);
以上所述是小编给大家介绍的C#实现图片上传(PC端和APP)保存及 跨域上传说明,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对脚本之家网站的支持!
您可能感兴趣的文章:
大家感兴趣的内容
12345678910
最近更新的内容
常用在线小工具静静好吃狗上传的图片
首先感谢大众点评让我中到这次霸王餐!好久没中过奖了,这次运气真好,让我提前偿试了下当新娘的感觉!收到中奖信息之后,就接到VIA的客服妹妹打来电话和我预约试纱时间,妹子说话很亲切。店面在茂业楼上12-36,出电梯左边,店面很大气,门口的橱窗摆放的婚纱模特特别漂亮,一眼就被吸引了!店里很干净,我到的时候有点早,她们还在做清洁,在门口就要换拖鞋进入,里面有很多婚纱,都很干净很新!具说今年5月份才开的,所以一切都很新!店主是化妆师,所以在这里选了婚纱还可以定化妆师哦,整体搭配效果会更好。因为我的婚期还早,所以只试了一件婚纱,是礼服师芳芳推荐给我的,一字肩的有很多水晶的婚纱,婚纱超级重,质量非常好。给我试妆的是化妆师娅娅,90后妹子,化妆很细致,一直不停的跟我交流沟通,边聊天边化妆,过程非常愉快!发型也一丝不苟,做得很仔细。完了还给我拍照留恋,整个过程花了3个小时,真是辛苦娅娅了!用的化妆品都很好,粉底是阿玛尼的哦,不用担心对皮肤不好啦!准新娘们一定不要错过VIA哦,很值得推荐的一家婚纱店!
静静好吃狗的相册color茜上传的图片
真是相当地拖延症,一直到现在才想起来写点评,也是因为月末降至。首先非常happy能抽中这个工作室的试拍,之前拍过一个婚纱套系的,所以一直还想抽中个工作室拍套自然清新的风格的。没想到这么快点评就满足了我。约了个周六的下午,时间非常好,在老妈的陪同下一起去了,然后可以去逛逛街。#位置和服务#就在东门地铁B出口鸿隆广场C座25楼,就在茂业奥特莱斯的旁边那栋很高的写字楼。沿着A座左边一直走就到了,然后电梯上去,这边都是商用两住的工作室类型。找到后看到门口贴着许多照片便确定是这家,不是非常大,就是一套房改成的工作室模样。到的时候摄影师和化妆师还在吃午饭,看到我们来了非常热情地接待。#挑衣服,化妆#它家的衣服明显偏少,就上下两排,说是后期会慢慢不断增多。有纱状的小礼服,长礼服,也有比较日常的毛衣,衬衫,裙子,来之前看了一下别人拍的,觉得拍日常的比较好看,所以挑了一件衬衫,然后试了三条裙子,最终确定了一条森系的棕色格仔半裙,期间化妆师和摄影师也会给出非常中肯的建议,非常的贴心,TIPS:试衣服的钩子真是小到可怜,强烈建议商家必须换个排钩子,我都是直接把衣服放在地下换的。实在是没办法挂。化妆师也是根据我挑选的衣服进行的化妆,突出眼部,使其明亮。其他的部位没有做过多的加重修饰,淡淡的感觉,眉毛也是细直眉。口红用的很颜色的桃红,已方便拍照时更鲜明。大概化妆有快一个小时。本来准备戴个帽子,由于只有贝雷帽,我又不适合,还是就披着自己的头发准备去拍了,拿了化妆师一个红色的边沿帽进去,看如果效果好就使用。#拍摄#摄影师阿风,非常年轻的一个帅哥,拍的时候完全专注在拍摄上,会教你怎么摆动作和表情的收放,道具用了麦穗和风干花,都非常喜欢,感觉就出来的效果非常棒,因为是我喜欢的小清新风格,正面背面都拍了很多张,远近也拍了很多,没有非常生硬的要你摆表情,所以出来的效果应该会自然很多,拍的时候就非常期待效果呀。拍完之后老板和老板娘一起把我们送进电梯,期间老板娘也一直跟我老妈聊天,非常地有亲和力,整个过程下来都感受到整个工作室非常和谐的氛围,大概过了三天,就用QQ把原片给了我,还有5张精修,比想象得更加好呀,只是自己太胖,后期剩下的原片都等靠自己了,速度非常地快呀。强烈安利给大家,现在有团购499的套系,包三套服装,非常划算的呀。主要是出来的片子好,喜欢自然清新风格的亲们可以去赶快尝试了。真人兽图片如下。哇咔咔,赶快撒花~
color茜的相册POCO摄影手机版
新导航介绍,
当前位置: &
切换模式:
如果喜欢这张图片,可以收录起来。
闪念,从一张图出发!收录此图与大家分享
版权声明:请尊重原创作品,转载时标明文章原始出处及作者信息
分享此作品 (0)
同时转帖到我的微博
推荐此作品
同时投上一票
近期大奖活动
| 按键盘←看作者的上一组作品,按键盘→键看作者的下一组作品
微信扫一扫,分享作品
帮助 & 服务
内容合作、出版发行合作联系方式:020-  
Copyright&
POCO CO.,LTD.
广告投放联系方式:华东:021-
华南:020-
华北:010-
POCO网违法和不良信息举报电话:
举报邮箱:}

我要回帖

更多关于 mongotemplate 保存 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信