Ha - sorry all. Rookie move. Here’s my code:
Here is the code where my form resides. It is a .php file. At the top, within the tag, I have:
<?php include 'upload_file.php' ?>
Below, in the body, is the form itself:
<form action="upload_file.php" method="post" enctype="multipart/form-data">
<label for="file">Filename:</label>
<input type="file" name="file" id="file"><br>
<input type="submit" name="submit" value="Submit">
</form>
Then another file in the same directory: “upload_file.php”:
[php]
<?php
$allowedExts = array("gif", "jpeg", "jpg", "png");
$temp = explode(".", $_FILES["file"]["name"]);
$extension = end($temp);
echo $_FILES . "
";
echo $_FILES['file'] . "
";
echo $_FILES["file"]["type"] . "
";
if
(
(
($_FILES["file"]["type"] == "image/gif") OR
($_FILES["file"]["type"] == "image/jpeg") OR
($_FILES["file"]["type"] == "image/jpg") OR
($_FILES["file"]["type"] == "image/pjpeg") OR
($_FILES["file"]["type"] == "image/x-png") OR
($_FILES["file"]["type"] == "image/png")
) AND
($_FILES["file"]["size"] < 20000) AND
( in_array($extension, $allowedExts) )
)
{
echo "DEBUG 1
";
if ($_FILES["file"]["error"] > 0)
{
echo "DEBUG 2
";
echo "Return Code: " . $_FILES["file"]["error"] . "
";
}
else
{
echo "DEBUG 3
";
echo "Upload: " . $_FILES["file"]["name"] . "
";
echo "Type: " . $_FILES["file"]["type"] . "
";
echo "Size: " . ($_FILES["file"]["size"] / 1024) . " kB
";
echo "Temp file: " . $_FILES["file"]["tmp_name"] . "
";
if (file_exists("uploadsTEST/" . $_FILES["file"]["name"]))
{
echo "DEBUG 4
";
echo $_FILES["file"]["name"] . " already exists. ";
}
else
{
echo "DEBUG 5
";
move_uploaded_file($_FILES["file"]["tmp_name"],
"upload/" . $_FILES["file"]["name"]);
echo "Stored in: " . "uploadsTEST/" . $_FILES["file"]["name"];
}
}
}
else
{
echo "DEBUG 6
";
echo "Invalid file";
}
?>
[/php]
It’s also worth noting that I have another directory within this one called “uploadsTEST” where I am attempting to have all uploaded images end up.
When I try uploading a 4kb jpeg file, I see my debug code echoed from the php file at the top of the page with the form. All echo’s at the top of the php file that have “$_FILE” are blank. Below that, I also see my debug code, which outputs “DEBUG 1” and then “DEBUG 6”, meaning it just thinks the file is invalid.
Thank you very much in advance. Sorry for the lengthy reply.
-Phil