PHP 上传图片
<html>
<head>
<meta http-equiv="Content-Type"
content="text/html;charset=UTF-8"/>
</head>
<body>
<form
action="load.php" method="post" enctype="multipart/form-data">
<input
type="file" name="uploadFile" id="upload"/> <br/>
<input
type="submit" value="上传" name="submit"/>
<br/>
</form>
</body>
</html>
<?php
if(is_uploaded_file($_FILES[‘uploadFile‘][‘tmp_name‘]))
$file
= $_FILES[‘uploadFile‘];
$type = $_FILES[‘uploadFile‘][‘type‘];
$name =
$file[‘name‘];
$tmp_name = $file[‘tmp_name‘];
$conn = mysql_connect("localhost","root","") or
die("数据库连接失败".mysql_error());
mysql_select_db("bbs");
mysql_query("set
names ‘utf8‘");
$sql = "UPDATE `users` SET `userImg`=‘D:/wamp/www/FG19/tempFile/$name‘ WHERE id=1";
$result = mysql_query($sql);
if($result){
move_uploaded_file($tmp_name,"../tempFile/".$name);
}
?>
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。