通过创建文件夹和Get Fileupload完整路径来上载文件 [英] File Upload by creating a folder and Get Fileupload full path
问题描述
我有一个FileUpload控件FcustPicUpload。
此客户可以上传他们的照片,这将保存在数据库中。
我想问2个问题..
1.我想将这些图片保存在上传/客户/customerID文件夹中,其中customerID文件夹将自动创建取决于关于customerID ..怎么做?
2.如何获取这些图片/文件的完整路径。我想在数据库中发送那些FullPath名称。
我使用的是ASP.NET 2012和SQL SERVER 2008
先谢谢
I have a FileUpload control "FcustPicUpload".
By this customer can upload their pictures and this will save in database.
There are 2 question i want to ask..
1. I want to save those pictures in Upload/ customer/"customerID" folder where customerID folder will create automatically depends on the customerID.. How to do it?
2. How to Get the full Path of those pictures/files. I want to send those FullPath name in Database.
I am using ASP.NET 2012 and SQL SERVER 2008
Thanks in Advance
推荐答案
string folder = HttpContext.Current.Server.MapPath("~/Upload/customer/" + customerID);
System.IO.Directory.CreateDirectory(folder);
string imageFile = HttpContext.Current.Server.MapPath("~/Upload/customer/1/photo.jpg");
FileUpload1.SaveAs(imageFile);
这篇关于通过创建文件夹和Get Fileupload完整路径来上载文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!