首页 > Web开发 > 详细

context.Request.Files为NULL问题 在实现图片上传功能的时候出现在ashx等处理页面出现context.Request.Files为NULL异常,有几点需要注意:

时间:2015-12-14 18:08:20      阅读:349      评论:0      收藏:0      [点我收藏+]

 

1、在客户端可以将form用submit提交,如下:

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <script src="JS/jquery-1.3.2.js" type="text/javascript"></script>
    <script language="javascript" type="text/javascript">
        function UpLoad() {
            $("#form1").submit();            
        } 
        
    </script>

</head>
<body>
    <form id="form1" method="post" enctype="multipart/form-data" action="ImageHandler.ashx">
    <div>
        <input id="File1" type="file" runat="server"/>
        <input id="Button1" type="button" value="上传" onclick="UpLoad()" /></div> 
        <div id="imgList"></div>      
    </form>
</body>
</html>

2、form表单需要加上属性method="post" enctype="multipart/form-data"

3、文件控件需要加上runat="server"属性

 

2、form表单需要加上属性method="post" enctype="multipart/form-data" 3、文件控件需要加上runat="server"属性

context.Request.Files为NULL问题 在实现图片上传功能的时候出现在ashx等处理页面出现context.Request.Files为NULL异常,有几点需要注意:

原文:http://www.cnblogs.com/yangpeng-jingjing/p/5045782.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!