How to send the source file path and file name without sending the file itself to ASP.NET?

How can I control an ASP.NET element that views files as a control FileUpload, but instead of renaming the entire file, it sends only the path from the file from which the file was found (with the original file name)?

0
source share
1 answer

Here is a workaround that I made following the instructions of the following forum post: http://forums.asp.net/p/1189182/2040139.aspx#2040048

<asp:FileUpload ID="File1" runat="server" onchange="GetFileName();"/> 
<asp:Button ID="Submit" runat="server" Text="Submit" OnClientClick="DisableFileSelector();" />
<asp:HiddenField id="txtFileName" runat="server" />

<script language="javascript" type="text/javascript">
    function GetFileName()
    {
        document.getElementById('<%=txtFileName.ClientID %>').value = document.getElementById('<%=File1.ClientID %>').value;
    }
    function DisableFileSelector() {
        document.getElementById('<%=File1.ClientID %>').disabled = true;
    }
</script>

, , JavaScript . JavaScript , , , , txtFileName.

if (File1.HasFile)
{
    txtFileName.Value = File1.PostedFile.FileName;
}
0

Source: https://habr.com/ru/post/1705261/