简单的上传文件方法!
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>无标题文档</title> </head> <body> <? $name=$_FILES["userimg"]["name"]; $tmp_name=$_FILES["userimg"]["tmp_name"]; move_uploaded_file($tmp_name,"img/".$name); $uploadfile="img/".$name; $path="http://10.10.132.222/x0936008/personinfo2/".$uploadfile; $username=$_POST["username"]; $sex=$_POST["sex"]; $birthday=$_POST["birthday"]; $hobby1=$_POST["hobby1"]; $hobby2=$_POST["hobby2"]; $hobby3=$_POST["hobby3"]; $hobby4=$_POST["hobby4"]; $color=$_POST["color"]; $img=$_POST["userimg"]; $info=$_POST["info"]; $imf=file_get_contents($path); $imf=addslashes($imf); $id=mysql_connect("localhost","x0936008","x0936008"); mysql_query("set names utf8",$id); mysql_select_db("x0936008"); $query="insert into personinfo2 values('','".$username."','".$sex."','".$color."','".$imf."','".$birthday."','".$info."')"; $result=mysql_query($query,$id); echo "<script language=javascript>alert('信息已存储成功点击确认查看!');location.href='display.php';</script>"; exit; mysql_close($id); ?> </body> </html>