HTML input file connection was reset error - html

We are trying to upload files to blob storage, the process currently works, however, when trying to upload a file greater than ~28.5MB through the HTML input type="file" element, a connection was reset error message appears. When debugging, the page never hits our httppost method in the C#. However all files we have tested under 28.5MB will upload correctly.
This is the file input in our cshtml page.
<input id="files" type="file" asp-for="UploadFiles" multiple />
Our form looks like this:
<form method="post" enctype="multipart/form-data" asp-area="JobManager" asp controller="KnowledgeBase" asp-action="EditItem">

There is a limit in Kestrel noted at https://github.com/aspnet/Announcements/issues/267.

Related

Why does submit button demand a local resource request to favicon.ico?

I've got a very basic form here in which I want to test whether the input text value is correctly picked up when clicking the submit button.
<form id="form1" onSubmit="console.log(document.getElementById('inkomen1').value)">
<input type="text" id="inkomen1" name="inkomen1">
<button type="submit" form="form1" value="Submit">Submit</button>
</form>
So I've set the form onSubmit to display the contents of the input text field through console.log. Live this works, but locally I always get this strange error in my console:
Not allowed to load local resource: file:///favicon.ico
Why doesn't this work when I text the file locally and why this request for 'favicon.ico'? Can I make it work locally somehow too?
It's has nothing to do with the code you included in your question. You have an HTML code that has a link to a favicon. The link has an absolute path file:///favicon.ico which is not correct when running your code in a different environment.
Use a relative path, if your favicon is in the same path as your HTML you can set it to:
/favicon.ico
UPDATE
Try to add custom action to your form
<form id="form1" action"targetPageHere" onSubmit="console.log(document.getElementById('inkomen1').value)">
Maybe the default action page is not your page and has a different code that include this reference.

Image uploading in a form

I am curious to know how image is uploaded in an HTML form.
I have seen at lots of places, that an image is being attached(like Gmail) or lots of other places where we select an image from disk to be processed on server.
So when exactly is the image is uploaded?
Just with the moment I choose an image.
It is encoded base64 and then sent with the form data.
Which one of these is true? And which should be used when?
When you click on choose file , file is attached .
When you click on form submit button , the form is submitted with selected file.
the image file is not encoded as base64 , it is sent to server as type of multipart
you need to set enctype="multipart/form-data" in your html form when you allow file to upload
<form action="" method="POST" enctype="multipart/form-data">
<input type="file" name="file">
<button type="submit">Submit</button>
</form>
you can set acceptable file formats in input type file

successful file upload opens new blank page, also allows "empty/blank" to upload

following code is working but with 2 issues: It is part of bigger form on the web page it appears on.
<FORM id="my_file_upld_form"
style="display: inline;"
METHOD="POST"
ACTION="/cgi-bin/fileupload_ajax.pl"
ENCTYPE="multipart/form-data">
<INPUT TYPE="file" class="ajaxfileupload" NAME="myfile" SIZE="42">
<input type="hidden" class="ajaxfileupload" name="fileupload" value="ajax_fileupload">
<input class="ajaxfileupload" type="submit" value="Upload"/>
</FORM>
it is allowing "blank" or empty (no file selection and upload button clicked) to upload. which is causing 500 error on server.
bigger problem is: after the file is uploaded, a new blank page is opened in browser and user has to use back button to go back to the page from where this was run. This happens irrespective of the fact that the ajax script returns anything back or not.
how to fix? I am open to replace this piece of code on the page, if needed.
It's hard to tell exactly what is going wrong without your java script code. However I think I know how to fix some of your problems.
Don't trust the client you need to handle in your backend code the ability to handle a form that gives you bad data. You can validate the form client side but you always need to validate server side as well.
I suspect this problem is happening because you aren't preventing the default event in javascript. In jquery you would do
$("#my_file_upld_form").submit(function(e){
e.preventDefault()
})

input type="file": Give option to open a local file or a file from the server

I have a website that asks the user to open a input file from his PC. This input file contains a lot of info. After opening the input file the user can click buttons and the website will search in the input file to display corresponding info.
It is a bit complex to create the input file. Therefore I want to give the possibility to test the website with an example file that is on the server. So the user can test the website before creating their own input file.
I have an example input file on the server.
How can I give the user the option to open a local input file, but also the example file from the server?
I use now (only local files):
Select your file:<input type="file" id="fileinput" />
Remark
It would also be ok for me if the user can open the example file via a button like <Open example file>.
When you say using input type=“file”, there is no such a way read a file on the server side, if you are coding B/S application, any file reading process need to be done on server end.
If you want user have some choices to read server file(on your server side), simply add a dropdown/checkbox list/radio button list what ever, make every choice reflect to one specific file on the server side, and then just read it on server end depends on which one selected.
The input type="file" will just be a post action to post the whole file to server end as well, you either store it on server end temp folder and parse it or read it directly from memory.
You could use radio buttons:
<fieldset>
<legend> input file <legend>
<div>
<label> <input type="radio" name="input_source" value="server"> Defaults </label>
</div>
<div>
<label> <input type="radio" name="input_source" value="upload"> From file </label>
</div>
<div>
<label> <input type="file" name="input_file"> Upload an input file </label>
</div>
</fieldset>
Alternatively, just use the file on the server if no file is uploaded.
<label> <input type="file" name="input_file"> Upload an input file (leave blank for defaults) </label>
<input type="file"> is only for uploading files. You can't browse server files with it.
You could use one of several web file browser scripts available, or write your own script to create that functionality, but it's not something that is available natively in HTML.
Can i browse file stored on Remote server through simple <input type="file"> control in asp.net MVC 2.0 - There are a few examples provided in the answer to this question, which is pretty close to yours.

Using <input type="file"> in Django

When someone clicks Submit after selecting a file with the <input type="file"> element, how do I access the contents of the file in Django?
(It seems like the request sent to the request handler has no trace of the file anywhere -- not even in request.FILES.)
Currently my template is like:
<form method="post" enctype="multipart/form-data">
<input type="file" enctype="multipart/form-data" name="file" accept="text/csv"/>
<input type="submit" value="Upload" />
</form>
View:
def HandleRequest(request):
print "**** request:", request
I don't see anything being printed about the file.
Note:
There's probably other ways to do this in Django, but I'm looking a solution using the simple input tag, and not something else (which would probably involve Javascript).
The code you posted, as it is posted, works fine. The HTML is sound (though I think the enctype on the <input> is redundant at best), and a very simple view shows an InMemoryFile after the POST. The problem must lie in something between the browser and your view. Some things to check:
Middleware.
Apache.
Nginx.
Decorators on your view.
mod_wsgi configuration.