文件上传功能 [英] file upload functionality
本文介绍了文件上传功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
使用< anchor>标签我无法查看上传的文件.同时查看一些额外的字符.例如"file//+ Pathname",我只需要路径名而不是前缀值..请给出解决方案,避免使用前缀字符串
using <anchor> tag i am not able to view uploaded files.while view some extra characters is coming.like "file//+Pathname" i need only path name not prefix value ..please give a solution avoid prefix string
推荐答案
我认为这会对您有所帮助
I think this will help you
if(FileUploadControl.HasFile)
{
try
{
string filename = Path.GetFileName(FileUploadControl.FileName);
FileUploadControl.SaveAs(Server.MapPath("~/") + filename);
StatusLabel.Text = "Upload status: File uploaded!";
}
catch(Exception ex)
{
StatusLabel.Text = "Upload status: The file could not be uploaded. The following error occured: " + ex.Message;
}
}
尝试正则表达式
http://stackoverflow.com/questions/223162/解析文件名-来自完整路径-使用常规表达式-c [
Try Regular expression
http://stackoverflow.com/questions/223162/parse-filename-from-full-path-using-regular-expressions-in-c[^]
这篇关于文件上传功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文