在Php中,我正在使用一些数据插入进行文件上传 我的表单看起来像这样
<form id="formID1" method="post" action="'.$_SERVER['REQUEST_URI'].'" enctype="multipart/form-data">
<label for="">'.$this->l('Add Store Type').'</label>
<input type="text" name="store_type" />
<label for="">'.$this->l('Upload Your Custom Icon').'</label>
<input type="FILE" name="custom_icon" id="custom_icon" />
<input type="submit" name="store_config" value="'.$this->l('Add Store Configuration').'" class="button" />
<form>
For uploading images I am doing a folder with 777 permission on it.
$uploaddir=dirname(__FILE__)."/storeconfig";
if(!file_exists($uploaddir)) {
mkdir($uploaddir, 777, true);
}
$tmpName=$uploaddir."/";
现在插入值我正在执行此代码。
if(isset($_POST['store_config'])) {
global $uploaddir;
$custom_icon_name = time().$_FILES['custom_icon']['name'];
$allowed_extensions = array('gif','jpg','png');
$path_info = pathinfo($custom_icon_name);
if( !in_array($path_info['extension'], $allowed_extensions)) {
echo "Incorrent file extension, Please Use png,jpg or gif files only";
} else {
if(mysql_query('INSERT INTO `'._DB_PREFIX_.'store_config` (`store_config_id`,`store_type`,`custom_icon`) VALUES ("","'.$store_type.'","'.$custom_icon_name.'") ')) {
if(move_uploaded_file($_FILES['custom_pin']['tmp_name'],$tmpName.$custom_icon_name)) {
echo "Settings updated successfully";
} else {
echo "You Have Some Errors";
}
}
}
}
这里的值在点击按钮Add Store Configuration
后成功存储到数据库中,但我仍然收到我在表单中设置的错误You Have Some Errors
。它应该显示设置已成功更新。有人能告诉我这是怎么回事吗?