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 6012359
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T02:23:35+00:00 2026-05-23T02:23:35+00:00

I have an upload attachment page in my .NET application. It works fine as

  • 0

I have an upload attachment page in my .NET application. It works fine as long as the uploaded file is smaller than 4 MB. How do I set the size of uploaded file? I’d like to set the limitation to be less than 8 MB. And if the file is larger than 8 MB, the upload process will be determined.

This is my code in the backend. File1 is the upload controler.

protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
{
    if ((File1.PostedFile != null) && (File1.PostedFile.ContentLength > 0))
    {
        string name=ViewState["UserName"].ToString();
        string fn = System.IO.Path.GetFileName(File1.PostedFile.FileName);
        string extension = Path.GetExtension(File1.PostedFile.FileName);
        if (extension == "")
            return;
        DirectoryInfo di = new DirectoryInfo(Server.MapPath("~/Attachments/" + name));
        FileInfo[] rgFiles = di.GetFiles("*.*");
        foreach (FileInfo fi in rgFiles)
        {
            if (fi.Name.Equals(fn))
            {
                ShowMessage(this, "This file name already exists, please check the list.");
                return;
            }
        }
        string SaveLocation = Server.MapPath("~/Attachments/" + name + "/" + fn);
        try
        {
            File1.PostedFile.SaveAs(SaveLocation);
            ShowMessage(this,"The file has been uploaded.");
        }
        catch (Exception ex)
        {

            ShowMessage(this,"Error" + ex.Message);
        }
        GetList();
    }
    else
    {
        ShowMessage(this,"Please choose one file");
    }
}
  • 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-05-23T02:23:36+00:00Added an answer on May 23, 2026 at 2:23 am
    <configuration>   
      <system.web>     
           <httpRuntime maxRequestLength="8000" />   
      </system.web> 
     </configuration> 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an upload form with a file to be uploaded. The issue I
I have an file upload box and a clear button on my page. When
Problem Statement: I have a aspx web page which supports file upload (ie. An
We have created a web application, using ASP.NET, that allows users to upload documents
I have a form in my html page, that prompts user to upload File
Before I have tried about doing one attachment (upload) for each record of my
I have a upload text file field, and with it I plan to save
I have an upload box... <form action=upload_file.php method=post enctype=multipart/form-data><BR> <label for=file>Filename:</label><BR> <input type=file name=file
I have an upload script that write a index.html file, I modified it to
I have to upload a file to an FTP server. The filename contains special

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.