I have been following a tutorial to create my first php application, a file (image) uploading system. I am hoping to add it to my site, http://www.kalam1ty.com/upload.php
I have read through the code multiple times and cannot find out what is wrong. I have tried to fix this for about half an hour now and cannot seem to find where the code is wrong. It does not generate any errors and passes all of the checks that I wrote, it just does not upload the image. Nothing in the upload part of the script looks off to me, but I am a PHP newbie, and am not 100% sure.
Here is the whole page's code:
<?php
if(isset($_FILES['image'])) {
$errors = array();
$allowed_ext = array('jpg', 'jpeg', 'png', 'gif');
$file_name = $_FILES['image']['name'];
$file_ext = strtolower(end(explode('.', $file_name )));
$file_size = $_FILES['image']['size'];
$file_tmp = $_FILES['image']['tmp'];
if(in_array($file_ext, $allowed_ext) === false) {
$errors[] = 'Extionsion not allowed.';
}
if($file_size > 10485760) {
$errors[] = 'File too large. Must be under 10MB.';
}
if(empty($errors)) {
//upload file
if (move_uploaded_file($file_tmp, 'uploads/images'.$file_name)) {
echo 'File uploaded to kalam1ty.com/uploads/images/';
}
} else {
foreach ($errors as $error) {
echo $error, '<br>';
}
}
}
?>
<html>
<head>
<title> Kalam1ty - Home </title>
<link rel="stylesheet" type="text/css" href="style.css" />
<link href='http://fonts.googleapis.com/css?family=Anonymous+Pro' rel='stylesheet' type='text/css'>
<link rel="shortcut icon" href="/home/corona/Development/Web/favicon.ico" type="image/x-icon" />
<meta name="google" value="notranslate">
</head>
<body>
<div id="EncBG">
<div id="Navbar">
<a href="index.php">Home</a>
<a href="downloads.php">Downloads</a>
<a href="upload.php">Upload</a>
<a href="contact.php">Contact</a>
</div>
<div id="Enc1">
<div id="Content">
<h2>Upload Files</h2>
<form action='' method='POST' enctype='multipart/form-data'>
<p>
<input type='file' name='image'>
<input type='submit' value='Upload'>
</p>
</form>
</div>
</div>
<div id="Footer" class="whitetext" align="center">
<b><i>
<a href="index.html">HOME</a>
//
<a href="downloads.html">DOWNLOADS</a>
//
<a href="#">OTHER</a>
</b></i><br>
<img src="smlogo.png" alt="Kalam1ty"/>
</div>
</div>
</body>
</html>
Thank you guys very much if you can help me!