i'm currently working on a project for an IT class i'm teaching, so i've set up this page on my website where students can upload html files, so they can see what the final result is. How exactly would i change the following code so students can only upload html files? or only html and png/jpg? Thank you! You can view the website here: http://ift.tt/1cNkTJi
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://ift.tt/kkyg93">
<html lang="en" xmlns="http://ift.tt/lH0Osb" xml:lang="en">
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content=
"width=device-width, initial-scale=1" />
<title>
File Upload
</title>
<link rel="icon" type="image/png" href="icons/favicon.png" />
<link href="css/bootstrap.min.css" rel="stylesheet" type=
"text/css" />
<script src="js/bootstrap.min.js" type="text/javascript"></script>
<script src="js/jquery-1.11.3.min.js" type="text/javascript"></script>
<script src="js/bootstrap-filestyle.js" type="text/javascript"></script>
<script src=
"http://ift.tt/1fK4qT1"
type="text/javascript"></script>
<script src=
"http://ift.tt/1knl5gY"
type="text/javascript"></script>
</head>
<body>
<div class="container" style=
"margin-top: 30px;margin-bottom: 30px">
<div class="row">
<div class="span12">
<h2 style="text-align: center;">
<strong>Alydus.net File Upload</strong>
</h2>
<div class="well">
<form role="form" enctype="multipart/form-data" method=
"post">
<h3>
Upload a file
</h3>
<hr />
<div class="row">
<div class="col-xs-6">
<div class="form-group">
<input type="file" name="example" id="input01"
class="filestyle" data-buttonbefore="true" />
<?php
$dir_upload = '/usr/local/nginx/html/upload/uploads/';
$max_size = 200000000;
$file = $_FILES['example'];
if ($file['size'] <= $max_size && $file['size'] > 0) {
$new_name = time() . '-' . $file['name'];
$copied = copy($file['tmp_name'], $dir_upload . $new_name);
if ($copied) {
print("Successfully uploaded to server, you can download/view the uploaded file now.");
} else {
print("An unknown error has occurred.");
}
} else {
print("");
}
?>
</div>
</div>
<div class="col-xs-2">
<div class="form-group">
<button type="submit" class=
"btn btn-primary">Upload File</button> <a href=
"http://ift.tt/1Ajn81F"
class="btn btn-primary" role=
"button">Download/view uploaded file</a>
</div>
</div>
</div>
</form>
</div>
<div class="container" style=
"margin-top: 30px;margin-bottom: 30px">
<div class="row">
<div class="span12">
<div class="well">
<form role="form" enctype="multipart/form-data"
method="post">
<h3>
Instructions
</h3>
<hr />
<div class="row">
<div class="col-xs-6">
<div>
<ul>
<li>Click choose file
</li>
<li>Select your file you'd like to
upload
</li>
<li>Click upload file once
</li>
<li>When the file is finished you
should see a complete message, then
click view/download uploaded file
</li>
<li>You can then copy the link and send
it to anyone so they can view your
images, your html files, and even
download your files!
</li>
</ul>
</div>
</div>
</div>
</form>
</div>
</div>
</div>
<div class="container" style=
"margin-top: 30px;margin-bottom: 30px">
<div class="row">
<div class="span12">
<div class="well">
<form role="form" enctype="multipart/form-data"
method="post">
<h3>
Files Uploaded
</h3>
<hr />
<div class="row">
<div class="col-xs-6">
<div style=
'width: 1015px; height: 2500px; overflow: hidden;'>
<center>
<iframe style=
'width: 1015px; height: 2500px;' src=
'http://ift.tt/1cNkTJk'>
</iframe>
</center>
</div>
</div>
<div class="col-xs-2"></div>
<center>
© <?php echo date("Y"); ?> Copyright
Alydus.net
</center>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</body>
</html>
Aucun commentaire:
Enregistrer un commentaire