我正在开发简单的内容管理系统,同时尝试上传图像没有发生任何事情。它只是刷新页面。我试过没有图像并且它可以正常工作,同时将图像添加到它不起作用
这是我的代码
if(isset($_POST[submit]) && $_FILES['userfile']['size'] > 0){
$information_id = mysql_prep($_GET['info']);
$menu = trim(mysql_prep($_POST['menu'])); // cut out whitespace for menu
$position = mysql_prep($_POST['position']);
$visible = mysql_prep($_POST['visible']);
$img_des = mysql_prep($_POST['img_des']);
$fileName = $_FILES['userfile']['name'];
$tmpName = $_FILES['userfile']['tmp_name'];
$fileType = $_FILES['userfile']['type'];
$fileSize = $_FILES['userfile']['size'];
$fp = fopen($tmpName, 'r');
$image = fread($fp, filesize($tmpName));
$image = addslashes($image);
fclose($fp);
$content = mysql_prep($_POST['content']);
if(!get_magic_quotes_gpc())
{
$fileName = addslashes($fileName);
}
$query = "INSERT INTO pages (
menu, position, visible, img_des, name, type, size, image, content, information_id
) VALUES (
'{$menu}', {$position}, {$visible}, '{$fileName}', '{$fileType}', {$fileSize},
{$image}, '{$img_des}', '{$content}', {$information_id} )";
if ($result = mysql_query($query, $connection)) {
$message = "The new page was created successfully";