Share via

Uploading files to Personal Website

Jctech2025 5 Reputation points
2026-05-06T18:28:43.1933333+00:00

Hi All, I don't believe I have posted to this forum.

So here's my issue. Running my own website in IIS on Windows 10. The site runs fine I can connect to it from anywhere using my ddnsname:port number. So I'm trying to make the feature where I can upload a file to the site from whatever devices I'm connected from. Here my code without giving away too much:

<form action="http://siteaddres:portnumber/Uploadfolder" method="POST" enctype="multipart/form-data"> <label style="color: white" for="myfile">Choose File to Upload:</label> <input type="file" id="myfile" name="filename"> <button type="submit">Upload</button>

Problem is every time I select the file from the machine I'm on and hit upload, it tells me the destination is either moved or unavailable. I am new to this. I'm sure I'm missing something. Thoughts? Thanks.

Windows for business | Windows Client for IT Pros | Devices and deployment | Set up, install, or upgrade
0 comments No comments

2 answers

Sort by: Most helpful
  1. AI answer

    2026-05-06T18:28:55.52+00:00

    The HTML form alone is not enough to upload a file to a folder in IIS. A server-side component must receive the POST, read the uploaded file, and save it to a physical path on disk.

    Key points:

    1. The form’s action should point to a server-side handler (for example, an ASP.NET page), not directly to a folder:
         <form action="http://siteaddress:portnumber/Upload.aspx" method="POST" enctype="multipart/form-data">
             <label style="color: white" for="myfile">Choose File to Upload:</label>
             <input type="file" id="myfile" name="myfile" />
             <button type="submit">Upload</button>
         </form>
      
    2. In the ASP.NET handler (for example, Upload.aspx.cs), use the file upload control to save the file to a folder on the server. The folder must exist and the IIS application pool identity must have write permissions to it. Example using a FileUpload control on an ASP.NET Web Form:
         using System;
         using System.IO;
         
         public partial class Upload : System.Web.UI.Page
         {
             protected void UploadButton_Click(object sender, EventArgs e)
             {
                 if (FileUpload1.HasFile)
                 {
                     string fileName = Path.GetFileName(FileUpload1.FileName);
                     string virtualPath = "~/Uploadfolder/" + fileName;
                     string physicalPath = Server.MapPath(virtualPath);
         
                     FileUpload1.SaveAs(physicalPath);
                 }
             }
         }
      
      Server.MapPath converts the virtual path (like ~/Uploadfolder/fileName) to the physical path on disk (for example, C:\Websites\YourSite\Uploadfolder\fileName). SaveAs then writes the file there.
    3. If using Razor Web Pages, read the uploaded file from Request.Files and save it using Path.GetFileName to strip the client path, then write it into a folder (for example, UploadedFiles) that exists under the site and is writable.
    4. The error “destination is either moved or unavailable” typically occurs because:
      • The form posts directly to a folder URL that IIS does not handle as an upload endpoint.
      • The target folder does not exist.
      • IIS does not allow writing to that location or the app pool identity lacks NTFS write permissions.

    Configure a proper upload handler (ASP.NET page or similar), ensure the upload folder exists under the site, and grant write permissions to the IIS application pool identity. Then point the form’s action to that handler instead of the folder.


    References:

    AI-generated content may be incorrect. Read our transparency notes for more information.

    Was this answer helpful?

    1 person found this answer helpful.
  2. Brian Huynh 2,960 Reputation points Microsoft External Staff Moderator
    2026-05-07T01:06:32.7866667+00:00

    Hello Jctech2025, thank you for posting in the Microsoft Q&A community.

    This behavior is completely expected based on your current HTML code. The issue is occurring because your form's action attribute is pointing directly to a folder directory (http://siteaddres:portnumber/Uploadfolder). By default, IIS does not know how to handle an HTTP POST request sent directly to a physical or virtual folder. An HTML form simply packages the file and sends it over the network, but IIS requires a server-side application (such as ASP.NET, PHP, Python, etc.) to actively receive that package, parse it, and write it to your hard drive.

     To resolve this, we need to introduce a server-side handler to receive the POST request and ensure your IIS permissions are correctly configured to allow saving the file.

    First, update your HTML form so the action points to a server-side script endpoint instead of a folder.

    Next, you will need to create the Upload.aspx script in your website's root directory to process the upload. Here is an ASP.NET C# example that receives the file and securely saves it into upload folder: 

    <%@ Page Language="C#" %>
    <%@ Import Namespace="System.IO" %>
    
     
    
    <script runat="server">
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Request.Files.Count > 0)
            {
                try
                {
                    var file = Request.Files[0];
                    if (file != null && file.ContentLength > 0)
                    {
                        string fileName = Path.GetFileName(file.FileName);
                        // Map the virtual path to the physical disk path
                        string savePath = Server.MapPath("~/Uploadfolder/") + fileName;
                        file.SaveAs(savePath);
                        Response.Write("File uploaded successfully.");
                    }
                }
                catch (Exception ex)
                {
                    Response.Write("Error: " + ex.Message);
                }
            }
        }
    </script>
    
    

    As a final step, IIS needs permission to write to your destination folder. By default, IIS runs websites under an application pool identity that only has "Read" access to protect your system.

    • Open File Explorer and navigate to the physical path of your website.
    • Right-click your Uploadfolder, select Properties, and go to the Security tab.
    • Click Edit, then click Add.
    • Type IIS_IUSRS in the object names box. 
    • Click Check Names and then click OK.
    • Select the newly added IIS_IUSRS group from the list, and check the Modify box under the Allow column. 
    • Click Apply and OK.

    If you are using a different web framework (like PHP or Node.js) instead of ASP.NET, please let me know your specific environment. Alternatively, to help us isolate the issue further, please check your IIS Logs located at %SystemDrive%\inetpub\logs\LogFiles and share the exact HTTP status code (e.g., 405 Method Not Allowed) generated when you click Upload.

    I will follow up on this thread to ensure your issue is resolved. If the guidance provided helped you navigate to this solution, please consider clicking 'Accept answer'. This officially marks the thread as answered and greatly helps other community members who are searching for a solution to this exact same problem.

    Was this answer helpful?


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.