所以我的图像没有更新到数据库,我收到了这个错误:
Warning: mkdir() [function.mkdir]: No error in C:\xampp\htdocs\phpfinal\pic_upload.php on line 36 error
我用谷歌搜索了这个,什么也没想到。请帮助我已注释掉第 37 行的位置
<?php
session_start();
$username = $_SESSION['sUserName'];
$conn = mysqli_connect("localhost", "writes", "digger")or die("cannot connect");
mysqli_select_db($conn,phpfinal)or die("cannot select DB");
?>
</head>
<body>
<span style="color:#FF0000"><?php echo $msg; ?></span><br />
<h2>Select File to upload</h2>
<form enctype="multipart/form-data" action="" method="post">
<input name="userfile" type="file" />
<input type="submit" value="Upload" name="Submit"/>
</form>
<?php
if ((($_FILES["file"]["type"]=='image/gif') || ($_FILES["file"]["type"]=='image/jpeg'))
&& ($_FILES["file"]["size"]<10000000))
{
if($_FILES["file"]["error"]>0)
{
} else {
$structure = 'uploaded_files/' .$username ."/";
}
}
if (file_exists ($structure))
{
move_uploaded_file ($_FILES["file"]["tmp_name"], $structure .$_FILES["file"]["name"]);
$img = $structure .$_FILES["file"]["name"];
} else {
mkdir($structure);
//line 37
move_uploaded_file ($_FILES["file"]["tmp_name"], $structure .$_FILES["file"]["name"]);
$img = $structure .$_FILES["file"]["name"];
}
$sql = "UPDATE users SET structure='image' WHERE username = '$username'";
//I'm not sure if the above line is right or wrong
$result = mysqli_query( $conn, $sql) or die(error);
print_r($result);
if($result){
echo "Update successful";
}
?>