码迷,mamicode.com
首页 > Web开发 > 详细

PHP 上传图片

时间:2014-05-27 02:44:26      阅读:354      评论:0      收藏:0      [点我收藏+]

标签:c   http   ext   a   数据   art   

<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);
}

 


?>

PHP 上传图片,布布扣,bubuko.com

PHP 上传图片

标签:c   http   ext   a   数据   art   

原文地址:http://www.cnblogs.com/gx9401142810/p/3735693.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!