如何在javscript中上传多个文件 [英] how to upload multiple file in javscript

查看:140
本文介绍了如何在javscript中上传多个文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

function addFileInput() {

var fileName = document.getElementById("uploadFile").value;
 //alert("hi:"+fileName);

    self.parent.displaySmallDocs.location.href="display_small_documents_GUI.asp?retrieve=yes&count=yes&doctype="+sDocType+"&filelist=" + fileName;

}

function CheckFileName() {
        var fileName = document.getElementById("uploadFile").value
         if (fileName.split(".")[1].toUpperCase() == "TIF"){
        addFileInput();
        }
           // return true;
        else {
            alert("File with " + file.fileName.split(".")[1] + " is invalid. Upload a valid file with tif extensions");
            return false;
        }
        return true;
    }



html代码



html code

<style type="text/css">
                 #container {
                    position: relative;
                    width: 4.00em;
                    height: 2.50em;
                    overflow: hidden;
                    background-image: url("../images/icons/search2.gif");
                    background-repeat: no-repeat;

                 }
                 #Search, #uploadFile {
                    position: absolute;
                    cursor: default;


                 }
                 #Search {
                    top: 0;
                    left: 0;
                    border: 1px solid #000;

                 }
                 #uploadFile {
                    opacity: 0.001;
                    font-size: 300%;
                    top: -5px;
                    right: -5px;

                 }

                    </style>
                    <!--[if IE]>
                    <style type="text/css">
                    #uploadFile {
                    filter:alpha(opacity=0.1);
                    }
                    </style>
                    <![endif]-->

                    <td>

                    <div id="container" title="Choose File">
                    <input id="uploadFile"  type="file" multiple  name='files[]' onchange="CheckFileName()"  >
                    <script language="javascript">
                        displayIcon("SearchButton","../images/icons/search2.gif","javascript:CheckFileName();","<%=Lan("SEARCH")%>");
                    </script>



如果有人知道,请帮忙.
还需要进行文件大小验证



please help if anyone knows it.
also need with file size validation

推荐答案

签出 Dropzone JS [ ^ ]

它是可定制的,可以满足您的需求.
Check out Dropzone JS[^]

Its customizable and could suit your needs.


这篇关于如何在javscript中上传多个文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆