|
CS479/579 - Web Programming II
|
Displaying ./code/Uploads/file.php
<?php
$mesg = "";
if (isset($_FILES['fx']['name'])) {
$name = $_FILES['fx']['name'];
if (strstr($name, "/")) die("File had slashes in it.");
if ($_FILES['fx']['error'] != 0) {
switch ($_FILES['upfile']['error']) {
case UPLOAD_ERR_OK:
break;
case UPLOAD_ERR_NO_FILE:
$mesg = 'No file sent.';
case UPLOAD_ERR_INI_SIZE:
case UPLOAD_ERR_FORM_SIZE:
$mesg = 'Exceeded filesize limit.';
default:
$mesg = 'Unknown errors.';
}
$mesg = "File upload error (" . $_FILES['fx']['error'] . ")";
}
if ($_FILES['fx']['error'] == 0) {
$dest = "/u1/h7/sbaker/public_html/cs479/code/11-02-Uploads/uploads/" . $name;
if (move_uploaded_file($_FILES['fx']['tmp_name'], $dest)) $mesg = "File was successfully uploaded.";
else $mesg = "Failed to upload file.";
}
}
?>
<!DOCTYPE html>
<html>
<head>
<title> File uploads </title>
<meta charset='utf-8'>
</head>
<body>
<h1><?php echo $mesg; ?></h1>
<form method=post enctype="multipart/form-data">
<input type=file name=fx><br>
<input type=submit>
</form>
</body>
</html>
|