forked from dxpsite/playflu
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreate.php
More file actions
139 lines (98 loc) · 4.18 KB
/
create.php
File metadata and controls
139 lines (98 loc) · 4.18 KB
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
<?php
require_once 'auth/auth.php';
// HTML authentication
authHTML();
include 'theme/header.php';
$descripton = "";
$description_err = "";
if($_SERVER["REQUEST_METHOD"] == "POST"){
// Validate name
$input_description = trim($_POST["descripton"]);
if(empty($input_description)){
$description_err = "Please enter a descripton.";
} elseif(!filter_var(trim($_POST["descripton"]), FILTER_VALIDATE_REGEXP, array("options"=>array("regexp"=>"/^[a-zA-Zа-яА-ЯёЁ0-9]+$/")))){
$description_err = 'Please enter a valid descripton.';
} else{
$descripton = $input_description;
}
}
?>
<nav class="navbar navbar-inverse navbar-fixed-top">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#">PlayFLU</a>
</div>
<div id="navbar" class="collapse navbar-collapse">
<ul class="nav navbar-nav">
<li><a href="https://subty.ru">Home</a></li>
<li class="active"><a href="https://subty.ru/addmedia/">Upload</a></li>
<li><a href="https://subty.ru/shed/">Sheduler</a></li>
<li><a href="https://subty.ru/settings/">Settings</a></li>
<li><a href="https://subty.ru/logout.php">Logout</a></li>
</ul>
</div><!--/.nav-collapse -->
</div>
</nav>
<div class="wrapper_">
<div class="container-fluid">
<div class="row">
<div class="col-md-12">
<div class="page-header">
<h2>Upload file</h2>
</div>
<p>Please fill this form and submit to add media record to the database.</p>
<!--<form action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]); ?>" method="post">-->
<form id="upload_form" enctype="multipart/form-data" method="post">
<script>
function _(el){
return document.getElementById(el);
}
function uploadFile(){
var file = _("file1").files[0];
// alert(file.name+" | "+file.size+" | "+file.type);
var formdata = new FormData();
formdata.append("file1", file);
var ajax = new XMLHttpRequest();
ajax.upload.addEventListener("progress", progressHandler, false);
ajax.addEventListener("load", completeHandler, false);
ajax.addEventListener("error", errorHandler, false);
ajax.addEventListener("abort", abortHandler, false);
ajax.open("POST", "upload/file_upload_parser.php");
ajax.send(formdata);
}
function progressHandler(event){
_("loaded_n_total").innerHTML = "Uploaded "+event.loaded+" bytes of "+event.total;
var percent = (event.loaded / event.total) * 100;
_("progressBar").value = Math.round(percent);
_("status").innerHTML = Math.round(percent)+"% uploaded... please wait";
}
function completeHandler(event){
_("status").innerHTML = event.target.responseText;
_("progressBar").value = 0;
}
function errorHandler(event){
_("status").innerHTML = "Upload Failed";
}
function abortHandler(event){
_("status").innerHTML = "Upload Aborted";
}
</script>
<!--<label>Description</label>
<input type="text" name="name" class="form-control" value="<?php echo $descripton; ?>">
<span class="help-block"><?php echo $description_err;?></span>
</div>-->
<input type="file" name="file1" id="file1"><br>
<input type="button" value="Upload File" onclick="uploadFile()">
<progress id="progressBar" value="0" max="100" style="width:300px;"></progress>
<h3 id="status"></h3>
<p id="loaded_n_total"></p>
</form>
<?php
include 'theme/footer.php';
?>