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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T20:42:10+00:00 2026-06-18T20:42:10+00:00

I have an asp uploader and when the user uploads an image it’s displayed,

  • 0

I have an asp uploader and when the user uploads an image it’s displayed, but the user can remove the image, but it’s not removed from Request.Files and then the image will be uploaded. How can I remove it from Request.Files from the javascript??

StepOne.aspx: http://pastebin.com/EUCX783r
StepOne.aspx.cs: http://pastebin.com/aZ3UtV2F

  • 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-18T20:42:11+00:00Added an answer on June 18, 2026 at 8:42 pm

    You cannot remove files directly from the FileList as it is readonly. You can remove all of the files within the Files collection by setting it to “” :

    document.getElementById('files').value = ""; //Removes all files in the input
    

    But this will not work for individual files.

    Suggested Workaround

    You can likely handle this by including a hidden input element within your form and monitoring the files that are marked for deletion within this hidden input.

    <input id='filesToDelete' name='filesToDelete' runat='server' type='hidden' />
    

    Upon performing your delete (assuming using Javascript), you can add the name of the file to your filesToDelete field (which will be comma-delimited) :

    //Within your delete Javascript method
    document.getElementById('filesToDelete').value += (yourImg.title + ",");
    

    When the uploads are posted to the server, you can specify to only upload those that are not contained within the list of files. Just store the comma-delimited values into a collection and if you prefer, use LINQ to check the collection and compare it to the posted files :

    protected void YourUploadButton_Click(object sender, EventArgs e)
    {
            //Get files to be deleted
            string[] filesToDelete = this.filesToDelete.Value.Split(',');
    
            //Your collection of files
            HttpFileCollection uploadFiles = Request.Files;
            for (int i = 0; i < uploadFiles.Count; i++)
            {
                //Checks the Posted File
                HttpPostedFile postedFile = uploadFiles[i];
                //If it isn't a file meant for deletion - don't upload
                if (!filesToDelete.Any(c => c == postedFile.FileName))
                {
                    UploadToFTP(postedFile, i);
                }
    
            }
    }
    

    You will just need to include a reference to LINQ at the top of your code-behind page :

    using System.Linq;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using asp.net mvc and have a section where a user can upload
I have an asp.net page where I am letting the user upload an image
I have a file manager application that is writed by asp.net MVC. User can
I have asp:GridView displaying client requests using asp:SqlDataSource . I want to limit displayed
I have a asp.net application which is working from last 2-3 years, it has
On my asp.net 4.0 site I have a upload function which allow a user
I have an asp.net application where the users can upload files to our database.
We have a CSV uploader where users can upload a CSV file filled with
I have file uploads working great on an ASP MVC3 web site. Currently the
I have a simple ASP.NET page that users can browse to, select a file

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.