小编dan*_*iel的帖子

PHP $ _FILES无法正确加载

我希望我能给你一个链接,但上次他们把它归咎于我所以这里是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> …
Run Code Online (Sandbox Code Playgroud)

html javascript php upload

-1
推荐指数
1
解决办法
533
查看次数

标签 统计

html ×1

javascript ×1

php ×1

upload ×1