Reputation: 312
My PHP upload script is not getting anything from my form. Here is my form:
<small>Must be JPG, max 200kb</small>
<input id="image" type="checkbox" name="image" value="yes">
<input type="file" name="file" id="file">
Here is the section of PHP that handles the upload, I know that $image does infact = 'yes', so it looks like the problem is with the $_FILES array, as $_FILES["file"]["size"] is empty:
if ($image=="yes" && $_FILES["file"]["size"]>0) {
if ((($_FILES["file"]["type"] == "image/jpeg")
|| ($_FILES["file"]["type"] == "image/pjpeg"))
&& ($_FILES["file"]["size"] < 200000))
{
if ($_FILES["file"]["error"] > 0)
{
$picstuff="Return Code: " . $_FILES["file"]["error"] . "<br />";
}
else
{
$picstuff= "Upload: " . $_FILES["file"]["name"] . "<br />
Type: " . $_FILES["file"]["type"] . "<br />
Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br /><br><br>
<center>Please note it can take a couple of minutes for the image to be processed.</center><br><br>";
move_uploaded_file($_FILES["file"]["tmp_name"], "images/$id.jpg");
$query="UPDATE content SET image='yes' WHERE `id`='$id'";
$result=mysql_query($query);
}
}
else
{
$picstuff = "Image too large or incorrect format. Please upload a jpeg less than 200kb.";
$image= "no";
$query="UPDATE content SET image='No' WHERE `id`='$id'";
$result=mysql_query($query);
}
} else
{
$picstuff = 'No File found';
$image= "no";
$query="UPDATE content SET image='No' WHERE `id`='$id'";
$result=mysql_query($query);
};
Every time I try upload I just get the 'No File found'. Would appreciate any help!
Upvotes: 0
Views: 205
Reputation: 312
I put enctype="multipart/form-data" into my form tag and it fixed my problem.
Upvotes: 1