Hi there...
Can someone please help me with the following code:
The field "Name repository" needs to be changed so that the user do not have to specify the file EXTENSION in the repository. It should automatically use the file selected and give it that name in the repository...
Any help please...!
Can someone please help me with the following code:
<script language="C#" runat="server">
void btnUploadTheFile_Click(object Source, EventArgs evArgs)
{
string strFileNameOnServer = txtServername.Value;
string strBaseLocation = @"c:\Users\Armandus\Documents\local_sites\XCSA_Intranet\pages\sap\repository\";
if ("" == strFileNameOnServer)
{
txtOutput.InnerHtml = "<br><strong>Error - a file name must be specified.</strong>";
return;
}
if (null != uplTheFile.PostedFile)
{
try
{
uplTheFile.PostedFile.SaveAs(strBaseLocation+strFileNameOnServer);
txtOutput.InnerHtml = "<br>File <b>" +
strBaseLocation+strFileNameOnServer+"</b> uploaded successfully.";
}
catch (Exception e)
{
txtOutput.InnerHtml = "<br>Error saving <b>" +
strBaseLocation+strFileNameOnServer+"</b><br>"+ e.ToString();
}
}
}
</script>
<table>
<form enctype="multipart/form-data" runat="server">
<tr>
<td>Select file:</td>
<td><input id="uplTheFile" type="file" runat="server"></td>
</tr>
<tr>
<td>Name in Repository:</td>
<td><input id="txtServername" type="text" runat="server"></td>
</tr>
<tr>
<td colspan="2">
<input type="button" id="btnUploadTheFile" value="Upload" OnServerClick="btnUploadTheFile_Click" runat="server">
</td>
</tr>
</form>
</table>
The field "Name repository" needs to be changed so that the user do not have to specify the file EXTENSION in the repository. It should automatically use the file selected and give it that name in the repository...
Any help please...!