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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T10:37:33+00:00 2026-06-01T10:37:33+00:00

I am making file input boxes through a javascrpit function, if the user wants

  • 0

I am making file input boxes through a javascrpit function, if the user wants to Attach more files, The function is

<script type="text/javascript">
var upload_number = 1;
var attachmentlimit = 5;
function addFileInput() {

var d = document.createElement("div");
var file = document.createElement("input");
file.setAttribute("type", "file");
file.setAttribute("name", "attach[]");
d.appendChild(file);
document.getElementById("moreUploads").appendChild(d);
upload_number++;
if(upload_number == attachmentlimit) {
      document.getElementById('moreUploadsLink').style.display='none';
    }

    }
    </script>

I am also checking the size of the File input at client through javascript function,

  <script type="text/javascript">
  var myFile = document.getElementById('attach');
    myFile.addEventListener('change', function() {
   var  size = this.files[0].size;
   alert(size,'File Size Exceeds'); 
   });
  </script>

The problem is, the above javascript function, gives the Size alert of only the first File Upload box, and not the others.
Any one who tell how to make this to provide sizes of all file uploads.

  • 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-01T10:37:35+00:00Added an answer on June 1, 2026 at 10:37 am

    Add the event listener to the file somewhere around d.appendChild(file). Otherwise, if you never tell JS to listen for the event, how can you expect it to?

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

Sidebar

Related Questions

I am asking the user to upload a file, through the following form making
I'm making a page where the user upload a file. I want an if
I'm using a script which replaces the usual file upload input with whatever image
I'm making a command-line word editor program. The user is prompted to input a
Hello i am making a program that is supposed to copy a text file.
I was wondering how I go about making an file upload input appear as
I'm making a .bat-file run a powershell script, and I need to make sure
I am making a CSS file for an XML document. I need to insert
I am making a libary file with functions for extra credit for computer programming
Is is possible to prevent Wget from making an output file when there is

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.