日期:2014-05-18 浏览次数:20496 次
HttpPostedFile postedFile = Request.Files["storyImg"];
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="WebApplication1._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>
</head>
<body>
<form id="form1" runat="server" enctype="multipart/form-data">
<input type="file" id="storyImg" name="storyImg" />
<input type="submit" id="save" class="riadd_btn" value="上传" />
</form>
</body>
</html>
------解决方案--------------------
<script type="text/javascript">
$(function() {
$("#form1").attr("enctype", "multipart/form-data");
});
</script>
-------------------------》
你原来的代码,改form的属性时错了,改成下面的样子
<script type="text/javascript">
$(function() {
$("#form1").attr("enctype", "multipart/form-data");
});
</script>