我想在Iframe Javascript PHP的帮助下,将单个ajax上传器脚本转换为多个上传器


I want to single ajax uploader script into multiple uploader with the help of Iframe Javascript PHP

我正在使用此引用http://www.openjs.com/articles/ajax/ajax_file_upload/response_data.php对于ajax上传器来说,它在单次上传时工作得非常好,但我想在您的指导下将此脚本转换为多次上传。我们也非常感谢您的帮助。。

我只想知道如何使用单个表单来针对多个iframe。当前脚本的目标是这样一个空间表单ID,而这个表单只包含一个输入文件。。。

代码

<script type="text/javascript">
function init() {
    document.getElementById("file_upload_form").onsubmit=function() {
     document.getElementById("file_upload_form").target = "upload_target";
     document.getElementById("upload_target").onload = uploadDone; 
    }
}
window.onload=init;
<script>
<form id="file_upload_form" method="post" enctype="multipart/form-data" action="http://www.appifylabs.com/web/php-upload-progress-bar/uploaderSecond/upload.php/">
<input name="file" id="file" size="27" type="file" multiple="multiple"/><br />
<input type="submit" name="action" value="Upload Image" /><br />
<iframe id="upload_target" onload="uploadDone()" name="upload_target"  src="" style="width:600px;height:600px;border:1px solid #ccc;"></iframe>
</form>

尝试无效

<script type="text/javascript">
    function init() {
        document.getElementById("file_upload_form").onsubmit=function() {
             document.getElementById("file_1").target = "upload_target_1";
             document.getElementById("file_2").target = "upload_target_2";
        }
    }
window.onload=init;
<script>

注意

我不想使用任何第三方上传程序,如uploadify、JqueryUploader、Valum等,这只是学习

的原因

每个表单只能有一个目标。target是FORM元素的属性,而不是INPUT元素的属性(您在上面尝试过)。

一种可能的解决方案是使用Jquery克隆表单,将相应的目标设置为所需的IFRAME,然后提交每个克隆。