PECL uploadprogress拡張機能を使用して、非常に基本的なAJAXアップロードプログレスバーを実装しようとしています。すべてのブラウザで機能するこのサンプルコードを見つけました:http ://svn.php.net/viewvc/pecl/uploadprogress/trunk/examples/ 。iframeを使用して更新を書き込みます。更新を取得し、jqueryを実行してプログレスバーを作成したいと思います。これが私のコードです(アップロードがいつ終了するかを説明するコードを記述していません)client.php:
<?php
$id = md5(microtime() . rand());
?>
<!DOCTYPE html>
<html>
<script type="text/javascript" src="jquery-1.7.2.min.js"></script>
<script type="text/javascript">
function getProgress(){
$.get("progress.php", {"ID":'<?php echo $id ?>'}, function(data){
console.log(data);
});
window.setTimeout(getProgress(), 5000);
}
</script>
<body>
<form onsubmit="getProgress()" target="_self" enctype="multipart/form-data" method="post">
<input type="hidden" name="UPLOAD_IDENTIFIER" value="<?php echo $id;?>" />
<label>Select File:</label>
<input type="file" name="file" />
<br/>
<label>Select File:</label>
<input type="file" name="file2" />
<br/>
<label>Upload File:</label>
<input id="submitButton" type="submit" value="Upload File" />
</form>
</body>
</html>
そしてprogress.php:
<?php
if (function_exists("uploadprogress_get_info")) {
$info = uploadprogress_get_info($_GET['ID']);
} else {
$info = false;
}
$progress = ($info['bytes_uploaded']/$info['bytes_total'])*100;
echo $progress;
エラーが発生し、出力されるのは0だけです。何か案は?