如何在Asp.net中上传文件(任何类型的文件) [英] How to upload a File (anytype of file) in Asp.net)

查看:84
本文介绍了如何在Asp.net中上传文件(任何类型的文件)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

plz帮助我解决紧急情况.如何在asp.net中上传文件

plz help me its urgent..how to upload a file in asp.net

推荐答案

使用以下任何文章
http://www.codeproject.com/search.aspx?q=file+upload+asp.net&x=0&y=0&sbo=kw&usfc=false [
Use any of these articles
http://www.codeproject.com/search.aspx?q=file+upload+asp.net&x=0&y=0&sbo=kw&usfc=false[^]


尝试此模板
try this template
<pre lang="xml"><%@ Page Language="C#" %>
<script runat="server">

    void SubmitButton_Click(Object sender, EventArgs e) {
       if (File1.PostedFile != null) {
          try {
             File1.PostedFile.SaveAs("C:\\Uploads\\uploadedfile.txt");
             Span1.InnerHtml = "Upload Successful!";
          }
          catch (Exception ex) {
             Span1.InnerHtml = "Error saving file <b>C:\\" +
                File1.Value + "</b><br>" + ex.ToString();
          }
       }
    }

</script>
<html>
<head>
</head>
<body>
    <form runat="server" enctype="multipart/form-data">
        Select a file to upload:<br />
        <input type="file" id="File1" runat="Server">
        <p>
        <input type="submit" id="Submit1" runat="Server"
         value="Upload File" OnServerClick="SubmitButton_Click">
        <p>
        <span id="Span1" runat="Server" />
    </form>
</body>
</html>






这篇关于如何在Asp.net中上传文件(任何类型的文件)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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