2

这没有任何用处。无论文件大小如何,我都会立即完成 100%。我不知道还能说什么,但显然必须说些什么,否则不会发布。

ini 文件片段:

; If you only provide the name of the extension, PHP will look for it in its
; default extension directory.

apc.rfc1867 = on
apc.rfc1867_freq = 100k
apc.max_file_size = 1024M
upload_max_filesize = 1024M
post_max_size = 1024M
apc.shm_size = 512M

;;;;;;;;;;;;;;;;;;;
; Module Settings ;
;;;;;;;;;;;;;;;;;;;

进度 PHP 脚本:

if ($status = apc_fetch('upload_'._GET['up_id'])) {
    if ($status['done']) $percent = 100;
    else if ($status['total'] == 0) $percent = 0;
    else $percent = $status['current'] / $status['total'] * 100;
    echo $percent;
    //echo json_encode($status);
}

Javascript:

var setupProgress = function() {
    var pbar;
    var started = false;
    var count = 0;
    $('#upload-form').submit(function() {
        $('#upload-form').hide();
        pbar = $('#progress_bar');
        pbar.parent().show();
        $('#upload_frame').load(function () {
            started = true;
            alert('Upload Complete!');
            pbar.parent().hide(400);
        });
        setTimeout(function () {
            updateProgress($('#uid').val(), pbar, started);
        }, 1000);
    });

    var updateProgress = function(id) {
        var time = new Date().getTime(); //make URL unique to prevent caching
        $.get('get_progress.php', {up_id:id, t:time}, function (data) {
            id$('prog_test').innerHTML += '<br />' + ++count + ':' + data;
            var progress = parseInt(data, 10);
            if (progress < 100 || !started) {
                started = progress < 100;
                setTimeout(function () {
                    updateProgress(id);
                }, 500);
            }
            started && pbar.css('width', progress+'%') && $('#progamt').html(progress+"%");
        });
    };
};

HTML:

<form id="upload-form" style="display:none" enctype="multipart/form-data" action='process_upload_phixed_image.php?<?= session_name(); ?>=<?= session_id(); ?>' method = "post" target="upload_frame">
    <div class="custom_file_upload">
        <span class="browse"></span>
        <span class="file_info">no file selected</span>
        <input type="hidden" name="APC_UPLOAD_PROGRESS" id="uid"  value="<?= $up_id; ?>"/>
        <input class="file_upload" type="file" id="phix_upload" name="file" />
    </div>
    <label>Price<input id="artist_price" name="artist_price" type="text" value=""></label>
    <label>Comment<input id="artist_comment" name="artist_comment" type="text" value=""></label>
    <div id="upload_btns">
        <input id="phix-upload" type="submit" value="Upload">
        <input id="cancel-upload" type="reset" value="Cancel">
    </div>
    <input id="upload_user_id" name="user_id" type="hidden" value="">
    <input id="loadedimage_source_id" name="loadedimage_source_id" type="hidden" value="">
    <iframe style="display:none" id="upload_frame" name="upload_frame" frameborder="0" border="0" src="" scrolling="no" scrollbar="no" ></iframe>
</form>
<div style="display:none" id="progress_bar_wrapper" class="rounded-small"><div id="progress_bar"><div id="progamt"></div></div></div>
<div style="display:none" id="prog_test">placeholder for progress checking</div>
4

0 回答 0