I want to add a custom field in General setting TAB in wordpress. This are the present fields that wordpress has it by default.
- Site Title
- Tag line
- Wordpress Address URL ...etc
I want to add a custom field like, I want to have an image upload field.
For that I had to edit
options-general.php ,
options.php,
general-template.php,
I had to insert an entry in wp-options table in my database
Now when I tested it with a simple input type as text it worked well.
But when I set the input type as file for my logo upload it doesn't work this is my code below.
options-general.php
<tr valign="top">
<th scope="row"><label for="logo"><?php _e('Logo') ?></label></th>
<td><input name="file" type="file"/></td>
</tr>
As you can see I have placed my image field right under my blog description field, and the action of this form takes me to options.php.
this is my option.php
if ( is_multisite() && !is_super_admin() && 'update' != $action )
wp_die(__('Cheatin’ uh?'));
/* image upload function goes here */
if($_POST['submit']){
$allowedExts = array("gif", "jpeg", "jpg", "png");
$temp = explode(".", $_FILES["file"]["name"]);
$extension = end($temp);
if ((($_FILES["file"]["type"] == "image/gif")
|| ($_FILES["file"]["type"] == "image/jpeg")
|| ($_FILES["file"]["type"] == "image/jpg")
|| ($_FILES["file"]["type"] == "image/pjpeg")
|| ($_FILES["file"]["type"] == "image/x-png")
|| ($_FILES["file"]["type"] == "image/png"))
&& ($_FILES["file"]["size"] < 20000)
&& in_array($extension, $allowedExts))
{
if ($_FILES["file"]["error"] > 0)
{
echo "Return Code: " . $_FILES["file"]["error"] . "<br>";
}
else
{
echo "Upload: " . $_FILES["file"]["name"] . "<br>";
echo "Type: " . $_FILES["file"]["type"] . "<br>";
echo "Size: " . ($_FILES["file"]["size"] / 1024) . " kB<br>";
echo "Temp file: " . $_FILES["file"]["tmp_name"] . "<br>";
if (file_exists("images/logo/" . $_FILES["file"]["name"]))
{
echo $_FILES["file"]["name"] . " already exists. ";
}
else
{
move_uploaded_file($_FILES["file"]["tmp_name"],"images/logo/" . $_FILES["file"]["name"]);
echo "Stored in: " . "upload/" . $_FILES["file"]["name"];
}
}
}
else
{
echo "Invalid file";
}
}
/* image upload function ends here */
Above I have added the simple image upload script, some how it doesn't work, nor the file is uploaded to the directory.
Does core PHP code works in WP environment Or I'm missing on something, Kindly suggest.

}option.phpin a couple of places, and this}images/logo/" . $_FILES["file"]["name"]))looks weird too. The SO syntax highlighter is showing code as strings and vice versa - you're missing a"somewhere.echoin each branch of your code, you should see some output if the code is running. Which seems to imply it's not running.$_POST['submit']definitely set? You've uploaded the right file to the right place? And there's nothing in the PHP logs? Core PHP does work in the WP environment, to answer that part of your question. Is$_FILESan array? Maybe you should loop over it?