【问题标题】:Ajax Upload errorAjax 上传错误
【发布时间】:2011-10-05 17:59:19
【问题描述】:

此文件索引

 <form name="classupload" method="post"  enctype="multipart/form-data" action="">
      <h3>Select pictures:&nbsp;</h3><br />
      <input type="file" name="Filedata[]" style="margin-top:2px;"/><br />
      <input type="file" name="Filedata[]" style="margin-top:2px;"/><br />

      <input type="file" name="Filedata[]" style="margin-top:2px;"/><br />
      <input type="file" name="Filedata[]" style="margin-top:2px;"/><br />
      <input type="file" name="Filedata[]" style="margin-top:2px;"/><br />
       <div id="viac"></div>
         <div style="margin-top:4px;"><a onclick="multiupload();">More</a><br /></div>
        <input type="submit" value="Upload" id="classupload"/>
      </form>

和文件 javascript

jQuery(document).ready(function() { 
$("#classupload").click(function() {
        var xleng=document.classupload.elements['Filedata[]'].length;
        dv = document.createElement("div");
        for (var i = 0; i < xleng ; i++)
        {
            img=document.classupload.elements['Filedata[]'][i].value;
            if(img.toString().length > 1){
                $.ajax({
                    type: "POST",
                    url: "upload.php",
                    data: img,
                    success: function(data_response) {
                        dv.innerHTML = i + ' - ' + data_response;
                    }
                });
            }
        }
        responseStatus("Done!");
        document.getElementById("result").appendChild(dv);

        return false; // avoid to execute the actual submit of the form.


    })

}); 

还有文件upload.php

    if ($_REQUEST['Filedata']) {

}

请帮我写文件upload.php显示文件 因为没有上传文件,我什么也得不到,请帮忙?

【问题讨论】:

    标签: php jquery ajax upload


    【解决方案1】:

    您不能直接通过 AJAX 上传文件。您需要一个使用隐藏 iframe 或利用 HTML5 功能的插件。

    【讨论】:

    • 但其他插件使用flashplayer
    • 依赖 Flash 是个坏主意。
    猜你喜欢
    • 2013-12-04
    • 2017-10-22
    • 1970-01-01
    • 1970-01-01
    • 2011-10-10
    • 2017-08-07
    • 2017-06-27
    • 2017-06-19
    • 2014-07-31
    相关资源
    最近更新 更多