将文章ID与上传的文件一起传递

时间:2014-03-13 21:06:39

标签: php jquery upload

我在这里使用jquery上传器。

这是我的按钮:

<!-- The fileinput-button span is used to style the file input field as button -->
<span class="btn btn-success fileinput-button">
    <i class="glyphicon glyphicon-plus"></i>
    <span>إضافة صورة</span>
    <!-- The file input field used as target for the file upload widget -->
    <input id="fileupload" type="file" accept="image/png" name="files[]">
</span>
<br>
<small>الحد الأقصى لحجم الملف هو 2.5 ميجابايت</small><br>
</td>
<td align="left" valign="middle">
<!-- The global progress bar -->
<div id="progress" class="progress" style="width: 300px">
    <div class="progress-bar progress-bar-success"></div>
</div>
<!-- The container for the uploaded files -->

这是我的jquery:

/*jslint unparam: true */
/*global window, $ */
$(function () {
    'use strict';
    // Change this to the location of your server-side upload handler:
    var url = window.location.hostname === 'blueimp.github.io' ?
                '//jquery-file-upload.appspot.com/' : 'jqueryupload/server/php/articlemedia/';
    $('#fileupload').fileupload({
        url: url,
        dataType: 'json',
        maxFileSize: 2500000,
        done: function (e, data) {
            $.each(data.result.files, function (index, file) {
                // $('<p/>').text(file.name).appendTo('#files');
                console.log("file", file.url) // see what this shows.
                $("#imgLogo").attr("src", file.url);
            });
        },
        progressall: function (e, data) {
            var progress = parseInt(data.loaded / data.total * 100, 10);
            $('#progress .progress-bar').css(
                'width',
                progress + '%'
            );
           window.location = '<?php echo $_SESSION["volow_domain_name"]; ?>memberarticlemedia?id=' + GetQueryStringValue('id');
        }
    }).prop('disabled', !$.support.fileInput)
        .parent().addClass($.support.fileInput ? undefined : 'disabled');
});

我想知道如何添加然后将其传递给UploadHandler.php,以便我可以在那里处理它(将其添加到数据库记录中)?

谢谢, 贾西姆

0 个答案:

没有答案