Итак, я пытаюсь выполнить загрузку с индикатором выполнения, я установил uploadprogress pecl, и загрузка работала отлично, если действие в форме приводит к upload.php
, любому другому имени, и оно перестает работать.
Если имя не upload.php
, вывод будет просто "100" (почему это видно ниже с файлом getprogress.php) это форма: (эти версии работают, так как файл upload.php)
<form method="post" action="/test/upload.php" enctype="multipart/form-data" id="upload-form" target="upload-frame">
<input type="hidden" id="uid" name="UPLOAD_IDENTIFIER" value="<?php echo $uid; ?>">
<input type="file" name="file">
<input type="submit" name="submit" value="Upload!">
</form>
</div>
<div style="float:left;width:100%;">
<div id="progress-bar"></div>
</div>
<iframe id="upload-frame" name="upload-frame"></iframe>
это jquery:
<script>
(function ($) {
var pbar;
var started = false;
$(function () {
$('#upload-form').submit(function() {
pbar = $('#progress-bar');
pbar.show().progressbar();
$('#upload-frame').load(function () {
started = true;
});
setTimeout(function () {
updateProgress($('#uid').val());
}, 1000);
});
});
function updateProgress(id) {
var time = new Date().getTime();
$.get('../uploadprogress/getprogress.php', { uid: id, t: time }, function (data) {
var progress = parseInt(data, 10);
if (progress < 100 || !started) {
started = progress < 100;
updateProgress(id);
}
started && pbar.progressbar('value', progress);
});
}
}(jQuery));
</script>
это файл getprogress.php
<?php
if (isset($_GET['uid'])) {
// Fetch the upload progress data
$status = uploadprogress_get_info($_GET['uid']);
if ($status) {
// Calculate the current percentage
echo round($status['bytes_uploaded']/$status['bytes_total']*100, 1);
}
else {
// If there is no data, assume it's done
echo 100;
}
}
?>
Я потратил около 5 часов на это, пытаясь понять, почему, и я не могу. Помощь будет принята с благодарностью.
upload.php
и значениеupload.php
в форме, это вообще не сработает? - person Jack   schedule 18.04.2012uploading.php
, вывод изgetprogress.php
всегда равен 100. если этоupload.php
, вывод представляет собой фактическое загруженное значение %. - person JimmyBanks   schedule 18.04.2012upload.php
наuploading.php
вместо того, чтобы просто изменить только значение формы, верно? - person Jack   schedule 18.04.2012