javascript - upload a file without having the submit button in mvc -
i want upload file without using submit button. file must uploaded @ moment user picks browse file window.
now please provide ajax code or jquery upload file , how delete file.
please provide control view this. view>>> <form action="fileuploadpost" method="post" enctype="multipart/form-data"> <label for="file1">filename1:</label> <input type="file" name="files" id="file3" /> <label for="file2">filename2:</label> <input type="file" name="files" id="file4" /> </form>
controller>>>
[httppost] public actionresult index(ienumerable<httppostedfilebase> files) { foreach (var file in files) { if (file.contentlength > 0) { var filename = path.getfilename(file.filename); var path = path.combine(httpcontext.server.mappath("~/app_data/uploads"), filename); file.saveas(path); } } return redirecttoaction("index"); }
you can use jquery file uploader control requirements. provides functionality upload file both "by clicking on button" , "auto upload".
auto upload : functionality upload file select file.
see ajax file upload step step implementation.
Comments
Post a Comment