I have a form and the action of the form is submit.php, what I am trying to do on submit.php to upload a file image, but when I click submit and print_r $_FILE an empty array appears. What am I doing wrong? I dont want to upload the file on the same page as the form. Here is the form:
<form action="in-the-press-submit.php" method="post">
<p>
<label for="title">Title:</label>
<input type="input" name="title" id="title">
</p>
<p>
<label for="posted-on">Posted On:</label>
<input type="date" name="posted-on" id="posted-on">
</p>
<p>
<label for="description" style="vertical-align:top;">Description:</label>
<textarea rows="20" cols="70" name="description" id="description"></textarea>
</p>
<p>
<label for="image">Image:</label>
<input type="file" name="image" id="image">
</p>
<p>
<input type="submit" name="submit" id="submit">
</p>
</form>
and here is my code in the submit page:
<?php
if ($_FILES["file"]["error"] > 0) {
echo "Return Code: " . $_FILES["file"]["error"] . "<br>";
} else {
move_uploaded_file($_FILES["file"]["tmp_name"],
"/image-test/" . $_FILES["file"]["name"]);
echo "Stored in: " . "/image-test/" . $_FILES["file"]["name"];
}
?>