Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8530905
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T09:21:45+00:00 2026-06-11T09:21:45+00:00

I have a simple ASP.NET page that users can browse to, select a file

  • 0

I have a simple ASP.NET page that users can browse to, select a file from their machine and upload it to my server. My remote users wish to automate uploading of files (using CURL) at their end.

As there is no user to click a button I need to do something to handle this, but what?

What changes do I need to make to have my web page handle the file upload without clicking a button?

Code Page…

using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Configuration;

namespace FileUpload
{
    public partial class _Default : System.Web.UI.Page
    {
        string UploadTo_Path = ConfigurationManager.AppSettings.Get("UploadTo_Path");
        protected System.Web.UI.HtmlControls.HtmlInputFile File1;
        protected void Page_Load(object sender, EventArgs e){ }
        protected void Button1_Click(object sender, EventArgs e)
        {
            UploadFile();
        }       
        private void UploadFile()
        { 
            if ((File1.PostedFile != null) && (File1.PostedFile.ContentLength > 0))
            {
                string fn = System.IO.Path.GetFileName(File1.PostedFile.FileName);
                UploadTo_Path += "\\" + fn;
                File1.PostedFile.SaveAs(UploadTo_Path);
                Response.Write("The file has been uploaded.");
            }
            else
            {
                Response.Write("Please select a file to upload.");
            }
        }
    }
}

Front End…

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="FileUpload._Default" Trace="true" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>File Upload</title>
</head>
<body>
    <form id="form1" runat="server" enctype="multipart/form-data">
        <input type="file" id="File1" name="File1" runat="server" />&nbsp;
        <asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Button" />
    </form>
</body>
</html>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T09:21:46+00:00Added an answer on June 11, 2026 at 9:21 am

    I’d do this differently.

    I’d check if the page was accessed using POST and then run UploadFile(), I wouldn’t use button with a click handler.

    On the client side the form would just do a normal form submit (a POST) to the page.

    This then lets CURL also access the page directly, without the need to do anything clever with JavaScript (which could be disabled and CURL doesn’t do).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a simple ASP.net page where users can edit information about themselves. When
I have an asp.net web page with a simple search text box that returns
I have a simple ASP.NET page that uses the VLC media player to play
I have an Asp .net page like this simple one http://issamsoft.com/app2/page1.aspx and I want
I have a pretty simple ASP.NET Web Form that looks a bit like the
So I have a simple voting feature on my asp.net mvc page. My index
I have a simple ASP.NET page where after the initial page load the user
I have created a simple login page for asp.net which takes in user name
I have a page in my ASP.NET web application that is essentially a tool
So, I'm making an ASP.NET page in C#. I have a very simple form

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.