开发者

PHP $_FILES doesn't load properly

I wish I could just give you a link but last time they blamed it all on me so here is the javascript code:

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'));

This is the 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>

My PHP Script: '; echo $_FILES['file']['name']1; ?>

and in the end here is my question:

after choosing 2 files it never wants to print array member [0] except when i delete second file it gives it array member value of 1 to the first element that initially had array member value of [0]

HERE is the link to see what is my story about


Looks like a typo.

 enctype="multipart/formdata"

needs to be

 enctype="multipart/form-data"
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜