PHP $ _FILES无法正确加载

dan*_*iel -1 html javascript php upload

我希望我能给你一个链接,但上次他们把它归咎于我所以这里是javascript代码:

function Multifile(list){
    this.id=0;
    this.list=list;

    this.createNew=function(element){
        element.name='file[]';
        element.multiFile=this;

        element.onchange=function(){
            var newElement=document.createElement('input');
            newElement.type='file';
            this.parentNode.insertBefore(newElement,this);
            this.multiFile.createNew(newElement);
            this.multiFile.addList(this);
            this.style.position='absolute';
            this.style.left='-1000px';
        };
    };

    this.addList=function(element){
        var newRow=document.createElement('div');
        var newButton=document.createElement('input');

        newButton.type='button';
        newButton.value='delete';
        newRow.element=element;

        newButton.onclick=function(){
            this.parentNode.element.parentNode.removeChild(this.parentNode.element);
            this.parentNode.parentNode.removeChild(this.parentNode);
            return false; //safari thing
        };

        newRow.innerHTML=element.value;
        newRow.appendChild(newButton);
        this.list.appendChild(newRow);
    };
};

var multifile=new Multifile(document.getElementById('fList'));
multifile.createNew(document.getElementById('file'));
Run Code Online (Sandbox Code Playgroud)

这是HTML:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title></title>
    </head>
    <body>
        <form id="upload" action="uploadPost.php" method="post" enctype="multipart/formdata">
            <input id="file" type="file"/>
            <input type="submit" value="upload"/>
        </form>
        <div id="fList">
        </div>
        <script type="text/javascript" src="javascriptcode.js">
        </script>
    </body>
</html>
Run Code Online (Sandbox Code Playgroud)

我的PHP脚本:'; echo $ _FILES ['file'] ['name'] 1 ; ?>

最后这是我的问题:

选择2个文件后,它永远不想打印数组成员[0],除非我删除第二个文件,它将数组成员值1赋予最初具有数组成员值[0]的第一个元素

这里是链接,看看我的故事是什么

Pek*_*ica 5

看起来像一个错字.

 enctype="multipart/formdata"
Run Code Online (Sandbox Code Playgroud)

需要是

 enctype="multipart/form-data"
Run Code Online (Sandbox Code Playgroud)