我用C#和ASP+来实现向WEB服务器指定的目录下上传文件,可是不能成功啊?帖很久了,救我啊!!!!
我用C#和ASP+来实现向WEB服务器指定的目录下上传文件,可是不能成功啊,有没有高手搞成功过,帮帮我啊,我觉得很简单啊,我只是上传图片而已。可我点击上传按钮根本就没有反映,我估计代码没有什么问题,可问题到底在什么地方啊?
我估计是什么地方设置的有问题,我的IIS设置如下:
虚拟目录:F:\Inetpub\wwwboot(F盘是NTFS的)
权限:读、写、执行都有了
这是我的代码:(实现不了想要的功能,传不上去)
<%@ Import Namespace="System.IO" %>
<%@ page Language="C#" debug="true" %>
<html>
<head>
<title>FileUpload </title>
<script language="C#" runat="server">
//This method is called when the 'upload' button ID pressed
public void UploadFile(object sender , EventArgs E)
{
//check if the fileposted is not null
if(myFile.PostedFile!=null)
{
//some string manipulations to extract the filename from the full file path
string nam = myFile.PostedFile.FileName ;
int i= nam.LastIndexOf("\\") ;
string newnm =nam.Substring(i) ;
myFile.PostedFile.SaveAs("c:\\inetpub\\wwwroot\\upload\\"+newnm) ;
fname.Text=myFile.PostedFile.FileName;
fenc.Text=myFile.PostedFile.ContentType ;
fsize.Text=myFile.PostedFile.ContentLength.ToString();
}
}
</script>
</head>
<body>
<form id="uploderform" method="post" action="FileUpload.aspx" enctype="multipart/form-data" runat="server" >
<table border="1" cellspacing="2" cellpadding="2" >
<tr> <td><h5>Select the File to upload</h5></td</tr>
<tr><td>
<input type="file" id="myFile" runat="server" >
</td></tr>
<tr><td>
<input type="button" value="Upload" OnServerClick="UploadFile" runat="server" >
</td></tr>
</table>
</form>
<br>
<br>
<table border="1" cellspacing="2">
<tr><td><b>File Details</b></td>
<td> </td>
</tr>
<tr>
<td>File Name :</td>
<td><asp:label id="fname" text="" runat="server" /></td></tr>
<tr>
<td>File Encoding :</td>
<td><asp:label id="fenc" runat="server" /></td></tr>
<tr>
<td>File Size :(in bytes)</td>
<td><asp:label id="fsize" runat="server" /></td></tr>
</table>
<br>
<br>
<br>
</body>
</html>
有搞成功的劳驾贴一下详细的步骤和代码啊,急急急急急急急急急急急急急急急,谢谢,高手要贴详细的过程啊:)!!!!!!!!!!!!!!!!!1
有高手告诉我设aspnet的权限,可是
怎么设置aspnet的权限啊,我不知道啊,麻烦大虾说具体一些好吗?
快救我吧,我已经头苦了好久了因为这个问题