Uploadify多个按钮-一页 [英] Uploadify Multiple buttons - one page

查看:72
本文介绍了Uploadify多个按钮-一页的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为客户创建一个网站,他希望能够在一个页面中包含许多上传按钮.当他单击选择文件时,uploadify将文件上传到服务器,然后将输入字段"Image"的值更改为图像的路径.

I am creating a website for a client, and he wants to be able to have in one page, many upload buttons. When he clicks select files, uploadify uploads the file to the server and then changes the value of the input field "Image" to the path of the image.

问题是我找不到在一个页面上具有多个上传按钮的方法,每个按钮都将单独填充它自己的div的图片"字段.客户端在同一页面中将有n个div.

The problem is that i cannot find a way to have multiple upload buttons in one page, where each one individually will fill it's own div's "Image" field. And the client will have n number of divs in the same page.

这是我的js代码:

$(document).ready(function() {
  $('.file_upload').uploadify({
    'uploader'  : 'content/plugins/category_manager/upload/js/uploadify.swf',
    'script'    : 'content/plugins/category_manager/upload/upload.php',
    'cancelImg' : 'content/plugins/category_manager/upload/js/cancel.png',
    'folder'    : 'content/plugins/category_manager/upload/uploads',
    'fileExt'       : '*.jpg;*.gif;*.png',
    'fileDesc'      : 'Image Files',
    'auto'      : true,
    'onComplete'  : function(event, ID, fileObj, response, data) {
        $("input[name=image]").empty(this).val(fileObj.name);
        }
  });
});

推荐答案

此代码:

jQuery(".file_upload").each(function() {
   jQuery(this).uploadify({
      height        : 30,
      swf           : '/uploadify/uploadify.swf',
      uploader      : '/script/uploadify/uploadify.php',
      width         : 120
   });
});

效果很好.

这还要求.file_upload元素中的id是唯一的,即使不使用它们.

This also requires that the ids in the .file_upload elements are unique, even if they are not used.

这篇关于Uploadify多个按钮-一页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆