简体   繁体   中英

JavaScript file upload is spotty

I have some code that uses the HTML input file type to upload XSL to a server-side program. While it works most of the time, once in a while the submit button will return with "The connection was reset," and my server will not have gotten anything (nothing was posted). Here's the code for the file upload, it's pretty standard:

<form action="upload.htm" method="POST" enctype="multipart/form-data" encoding="multipart/form-data">
<input type="file" id="datafile" onchange="checkFileType(this.value)" /><br/>
<input type="submit" id="datasubmit" value="Send" onclick="submitConfirm()" disabled />
</form>

checkFileType will enable and disable the submit button according to filetype, and submitConfirm just hides the form and shows a div containing "Uploading...".

I may be entirely off with this, but I have found that using an XSL file that's larger (60kb) will fail every single time, whereas my original tests with a small file (15kb) worked every time. Is there a size limit to uploading, or is there something I'm missing?

Edit: Also, just to throw it out there, the other case I the file upload to fail consistently with was when I tried to upload non-XSL files (before I implemented the checkFileType function). These non-XSL files were mostly shortcuts, so less than 10kb.

What are you using for your web server? The web server may have a limit on uploaded file size. I know that in IIS + ASP.NET, that limit had to be changed.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM