如何使用asp在.net网站上传文件? [英] how to upload file in a .net website using asp?

查看:71
本文介绍了如何使用asp在.net网站上传文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在asp.net网站上传文件?

how to upload file in a asp.net website??

推荐答案

这是一个如何使用文件上传控件的简单示例:



This is a simple example of how you can use a file upload control:

try
{
       //here you are specifying where the file will be saved and then saving the file
       string filename = "A path on the machine" + FileUpload1.FileName.ToString();
       FileUpload1.SaveAs(filename);

       FileInfo file = new FileInfo(filename);

           //here you are checking if the file exists before going on
           if (file.Exists)
           {
               String conString = "";
               String connstr = "";

               //this is just checking the file extension and is optional
               if (filename.EndsWith(".xlsx"))
               {
               }
           }
}
catch (Exception e)
{
}


这篇关于如何使用asp在.net网站上传文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆