D
Dam6
Hello there,
I'm using the below code and it works, but as usual, it does not quite give
me everything I need:
No matter what file I click on, it only ever save the file as test.txt and
that's my problem... This upload function will be used for various filetypes
and thus i need the code to take the filename of the file I am uploading,
or, somehow ask me what filename I would like!
Any ideas?
<%@ Page Language="C#" ContentType="text/html" ResponseEncoding="iso-8859-1"
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Upload</title>
<script runat="server">
void btnUploadFile_OnClick( Object o, EventArgs e )
{
fileUpload.PostedFile.SaveAs(Server.MapPath("test.txt") );
}
</script>
</head>
<body>
<form runat="server" enctype="multipart/form-data">
<input name="fileUpload" type="file" id="fileUpload" runat="server">
<asp:button ID="btnUploadFile" runat="server" Text="Upload File"
OnClick="btnUploadFile_OnClick" />
</form>
</body>
</html>
I'm using the below code and it works, but as usual, it does not quite give
me everything I need:
No matter what file I click on, it only ever save the file as test.txt and
that's my problem... This upload function will be used for various filetypes
and thus i need the code to take the filename of the file I am uploading,
or, somehow ask me what filename I would like!
Any ideas?
<%@ Page Language="C#" ContentType="text/html" ResponseEncoding="iso-8859-1"
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Upload</title>
<script runat="server">
void btnUploadFile_OnClick( Object o, EventArgs e )
{
fileUpload.PostedFile.SaveAs(Server.MapPath("test.txt") );
}
</script>
</head>
<body>
<form runat="server" enctype="multipart/form-data">
<input name="fileUpload" type="file" id="fileUpload" runat="server">
<asp:button ID="btnUploadFile" runat="server" Text="Upload File"
OnClick="btnUploadFile_OnClick" />
</form>
</body>
</html>