-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.php.old
45 lines (45 loc) · 1.56 KB
/
index.php.old
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
<!-- It's a test rig; not full HTML yet-->
<form enctype="multipart/form-data" action="upload.php" method="POST">
<input type="hidden" name="MAX_FILE_SIZE" value="10000000" />
Send this file: <input name="userfile" type="file" />
<input type="text" style="display:none;" name="verify1" value="" />
<input type="text" style="display:none;" name="verify2" value="swag" /> <!-- replace with CSRF or something -->
<input type="submit" value="Send File" />
</form>
<progress id="swag" style="display:none;"></progress>
<pre></pre>
<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script type="text/javascript">
$("form").submit(function(e){
e.preventDefault();
var formData = new FormData($(this)[0]);
$("#swag").show();
$.ajax({
url: "upload.php",
type: 'POST',
data: formData,
async: true,
xhr: function(){
var xhr = jQuery.ajaxSettings.xhr();
if(xhr instanceof window.XMLHttpRequest) {
xhr.upload.addEventListener("progress", function(evt){
if (evt.lengthComputable) {
var percentComplete = evt.loaded * 100 / evt.total;
console.log("Progress: ", percentComplete);
$("#swag").attr("max","100").attr("value",percentComplete);
}
}, false);
}
return xhr;
},
success: function (data) {
$("#swag").hide();
$("pre").text(JSON.stringify(data));
},
cache: false,
contentType: false,
processData: false
});
return false;
});
</script>