Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

148
Views
MVC How to read an uploaded file in jquery

I am doing an MVC App, and i am uploading a file... On Submit i am sending the file to the Controller. But before that, I need to know the file´s name and count of lines...

The only thing i can not do is to read the file. I dont know if it si possible...

This is what I have

<form action="@Url.Action("Save","PaymentUpload")" id="form" enctype="multipart/form-data" method="post">
        <div class="form-group row">
            <div class="col-md-9" style="float: left;">
                <div class="upload-payment">
                   <div class="file-upload">
                        <input type="file" class=" btnCustom input-file" id="PaymentsFile" name="PaymentsFile" accept=".CSV">
                    </div>
                    <div class="button-process">
                        <span class="pull-left">
                            <button class="btnCustom btn-success" type="submit" id="btnTest">Process Payment</button>
                        </span>
                    </div>
                </div>
            </div>
        </div>
 </form>

On Submit I have this. On BeforeSend I check for fileName.. I need to open the file i know the number of lines...

$('form').submit(function (event) {
            event.preventDefault();
                var formdata = new FormData($(this).get(0));
                $.ajax({
                    url: this.action,
                    type: this.method,
                    data: formdata,
                    processData: false,
                    contentType: false,
                    beforeSend: function ()
                    {
                        var fileUpload = $("#PaymentsFile").get(0);
                        var files = fileUpload.files;
                      //Get the file Name
                        var name = files[0].name;
                     
                       //Get rows count...????
                    },
                    success: function (result) {
                       // processResponse(result);
                    },
                    complete: function () {
                    }
                });
     });

It is a way to achieve this?

Thanks

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!