I have a form:
<form method="post" action="includes/tagcreate.php">
<input type="file" name="image" />
<input class="btn btn-orange" name="submit" type="submit" value="Create" />
</form>
And tagcreate.php:
require('connection.php');
if (isset($_POST["submit"])) {
$image = $_POST['image'];
$userfile_name = $_FILES["image"]["name"];
$large_image_location = '../';
$query = "INSERT INTO tags (image) VALUES ('{$image}')";
if (isset($_FILES["image"]["name"])){
move_uploaded_file($userfile_name, $large_image_location);
chmod ($large_image_location, 0777);
}
if (mysql_query($query, $connection)) {
header("location: ../");
exit;
} else {
echo "<p>Failed to add:</p>";
echo "<p>" . mysql_error() . "</p>";
}
}
So the database query is working fine but... no file. I haven't really dealt with uploads before so I feel like I might be missing something fairly obvious here.