제

화일 업로드시 시각적으로 표시를...

· 2013-05-08 (수) 18:44:40 · 619
화일 업로드시 가로바가 표시되면서 업로드상태를 % 로 표시 할수 있는 방법 없을까요 ?
업로드시 화면상에 아무 표시가 없어 상태를 알수가 없습니다.

인터넷 검색 해 보니까...
이런 소스가 있더라구요...

아래의 소스를 정리해서 사용 해 봤는데...
잘 되질 않습니다.



<!doctype html>
<head>
<title>File Upload Progress Demo #1</title>
<style>
body { padding: 30px }
form { display: block; margin: 20px auto; background: #eee; border-radius: 10px; padding: 15px }

.progress { position:relative; width:400px; border: 1px solid #ddd; padding: 1px; border-radius: 3px; }
.bar { background-color: #B4F5B4; width:0%; height:20px; border-radius: 3px; }
.percent { position:absolute; display:inline-block; top:3px; left:48%; }
</style>
</head>



<body>
<h1>File Upload Progress Demo #1</h1>
<code><input type="file" name="myfile"></code>

<form action="file-echo2.php" method="post" enctype="multipart/form-data">
<input type="file" name="myfile"><br>
<input type="submit" value="Upload File to Server">
</form>

<div class="progress">
<div class="bar"></div >
<div class="percent">0%</div >
</div>

<div id="status"></div>


<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.js"></script>
<script src="http://malsup.github.com/jquery.form.js"></script>
<script>


(function() {

var bar = $('.bar');
var percent = $('.percent');
var status = $('#status');

$('form').ajaxForm({
beforeSend: function() {
status.empty();
var percentVal = '0%';
bar.width(percentVal)
percent.html(percentVal);
},
uploadProgress: function(event, position, total, percentComplete) {
var percentVal = percentComplete + '%';
bar.width(percentVal)
percent.html(percentVal);
},
success: function() {
var percentVal = '100%';
bar.width(percentVal)
percent.html(percentVal);
},
complete: function(xhr) {
status.html(xhr.responseText);
}
});

})();
</script>

<script src="http://www.google-analytics.com/urchin.js" type="text/javascript"></script>
<script type="text/javascript">
_uacct = "UA-850242-2";
urchinTracker();
</script>
|
댓글을 작성하시려면 로그인이 필요합니다.

그누5 질답

1,039건

그누보드5 버전에 대한 질문을 할 수 있습니다.쪽지나 메일로 해결해 주겠다는 답변은 정상적인 답변으로 보기 어려우므로 신고해 주시기 바랍니다.

+
제목 글쓴이 날짜 조회
13-05-11 조회 465
13-05-11 조회 416
13-05-10 조회 446
13-05-09 조회 1,112
13-05-09 조회 832
13-05-09 조회 597
13-05-08 조회 620
13-05-08 조회 686
13-05-07 조회 673
13-05-06 조회 791
13-05-06 조회 613
13-05-05 조회 552
13-05-05 조회 823
13-05-04 조회 666
13-05-04 조회 776
13-05-04 조회 627
13-05-04 조회 608
13-05-03 조회 513
13-05-03 조회 511
13-05-03 조회 423