forked from thoraxe/openshift-php-upload-demo
-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathupload.php
39 lines (30 loc) · 1.12 KB
/
upload.php
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
<?php require_once("includes/header.php") ?>
<section class='container'>
<hgroup>
<h1>Result</h1>
</hgroup>
<?php
// Doesn't do any sort of checking on the file validity just yet.
$upload_dir = "uploaded/";
$filename = $upload_dir . basename($_FILES["fto"]["name"]);
$uploadValid = 1;
if ($_FILES["fto"]["size"] > 204800000) {
echo "Your file is too large. Please upload a file that is smaller than 20MB.";
echo '<a href="./index.php">Home Page</a><br>';
$uploadValid = 0;
}
if ($uploadValid == 0){
echo "Error: Your file cannot be uploaded as-is. Please make sure it's the correct size before attempting again.";
echo '<a href="./index.php">Home Page</a><br>';
} else {
if (move_uploaded_file($_FILES["fto"]["tmp_name"], $filename)) {
echo "The file " . basename( $_FILES["fto"]["name"]). " has been uploaded.<br>";
echo '<a href="./index.php">Home Page</a><br>';
echo '<a href="./listfiles.php">List Uploaded Files</a>';
} else {
echo "An unknown error has occurred. Please try again.";
echo '<a href="./index.php">Home Page</a><br>';
}
}
?>
<?php require_once("includes/footer.php")?>