question

JoseArturoElizondo-6659 avatar image
0 Votes"
JoseArturoElizondo-6659 asked AgaveJoe edited

Input string was not in a correct format files

Hello, I try upload file excel, but there show me this error:

FormatException: Input string was not in a correct format.

System.Number.StringToNumber(ReadOnlySpan<char> str, NumberStyles options, ref NumberBuffer number, NumberFormatInfo info, bool parseDecimal)

  84:       var file = Request.Form.Files;

also I try this IFormFile file = Request.Form.Files[0]; and same error

I send the file from ajax

var formData = new FormData();
formData.append('files', $('#FileUpload1')[0].files[0]);
formData.append('canal', $("#proviene option:selected").text());

             $.ajax({
                 url: "/Facturas/import",
                 type: 'POST',
                 data: formData,

I use ASP.NET core 2.1 mvc

Also, it is strange, another computer is working, but on the server is not working. Some idea?
Thanks!!

dotnet-aspnet-core-mvc
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

This is a very common error when trying to convert a string to an integer when the string is not a number. As far as I can tell, the code you've share has nothing to do with the error. I recommend doing a little basic debugging to find the line of code and string that is causing the error. Once you find where the code is erroring, then you should be able to fix it.

0 Votes 0 ·

0 Answers