Jquery ajax uploader with query string

时间:2012-06-11 09:36:24

标签: php jquery ajax

我使用以下插件上传进度条

http://blog.stevensanderson.com/2008/11/24/jquery-ajax-uploader-plugin-with-progress-bar/

jQuery(document).ready( function () { 
         $(".flupload").makeAsyncUploader({
        upload_url: "upload_logo_file.php?pid="+($(this).attr("id")), 
        flash_url: 'swfupload.swf',
        button_image_url: 'blankButton.png'
    });

    });

在我的html表单中,我使用了floowing

<input type="file" id="1550" name="1550" class="flupload" />
<input type="file" id="1552" name="1552" class="flupload" />

上传进度条在这里工作正常。但我的问题是:我想通过'Upload_url'参数传递id(1550或1552)。

为此使用了以下

upload_url: "upload_logo_file.php?pid="+($(this).attr("id")), 

但在使用($(this).attr(“id”))时未检索到Id

如何获取当前的ID。

请帮忙。

1 个答案:

答案 0 :(得分:1)

您的ID不是有效的html ID。请改为使用自定义data属性,如下所示:

<input type="file" data-id="1550" name="1550" class="flupload" />

upload_url: "upload_logo_file.php?pid="+$(this).data("id"),