Popular blog tags

File various upload methods

Published

As programmers, we often use file upload and download functions. When you need it, check out all the information. Yes, there is wood....

Here's a summary and a memo to make sure you're going to use it next time.

First:Use form to achieve file upload form, asynchronous upload The most primitive, simplest, and most brutal file uploads.

Front end code:

<form action="/Home/SaveFile1" method="post" enctype="multipart/form-data">

<input type="file" class="file1" name="file1" />

<button type="submit" class="but1">上传</button>

</form>  

Second:Form asynchronous upload

Although the above method is simple and crude, it is not friendly enough. The page is sure to refresh. Difficult to stay in the current page, and gives the file upload success tips.As time goes by, technology changes with each passing day. The advent of Ajax makes asynchronous file delivery easier.Next, we use the jquery.form plug-in to implement asynchronous upload of files

<form id="form2" action="/Home/SaveFile2" method="post" enctype="multipart/form-data">

<input type="file" class="file1" name="file1" />

<button type="submit" class="but1">上传1</button>

<button type="button" class="but2">上传2</button> </form>.