Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

149
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda