我的位置: 首頁(yè) > 學(xué)習(xí)專(zhuān)區(qū) > PHP技術(shù) > php基礎(chǔ)教程:把文件上傳到服務(wù)器

php基礎(chǔ)教程:把文件上傳到服務(wù)器

2013-04-10 09:33:46
來(lái)源:
[導(dǎo)讀] php基礎(chǔ)教程:把文件上傳到服務(wù)器conn.php:<?php $id=mysql_connect(&#39;localhost&#39;,&#39;root&#39;,&#39;root&#39;);mysql_select_db...
php基礎(chǔ)教程:把文件上傳到服務(wù)器

conn.php:

<?php 
$id=mysql_connect('localhost','root','root');
mysql_select_db("db_database12",$id);
mysql_query("set names gb2312");
?>

index.php:

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>限制大小的文件上傳</title>
<style type="text/css">
<!--
body {
	margin-left: 00px;
	margin-top: 0px;
	margin-right: 0px;
	margin-bottom: 0px;
}
-->
</style></head>

<body>
<table width="385" height="185" border="0" cellpadding="0" cellspacing="0" background="image/316.JPG">
  <tr>
    <td width="130" height="75">&nbsp;</td>
    <td width="200">&nbsp;</td>
    <td width="55">&nbsp;</td>
  </tr>
  <form name="form1" method="post" action="index_ok.php" enctype="multipart/form-data">
  <tr>
    <td height="38">&nbsp;</td>
    <td align="center" valign="middle"><input name="file3" type="file" id="file3" size="15" maxlength="150">
   </td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td height="30" align="right">&nbsp;</td>
    <td align="center" valign="top"><input type="submit" name="Submit" value="提交">&nbsp;&nbsp;&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
  </form>
  <tr>
    <td height="42">&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
</table>
</body>
</html>

index_ok.php:

<?php 
session_start(); 
include("conn.php");?>
<?php
 if($Submit=="提交"){
$data=date("Y-m-d");
$file_name="files";
$filesize=$_FILES['file3']['size'];
if($filesize>2000000){
echo "對(duì)不起,您上傳的文件超過(guò)了規(guī)定的大小!!";
echo "<meta http-equiv=\"Refresh\" content=\"3;url=index.php?lmbs=文件上傳\">將在3秒鐘后返回前頁(yè)...";
}else{
$path = './upfiles/'. $_FILES['file3']['name'];
if (move_uploaded_file($_FILES['file3']['tmp_name'],$path)) { 
	$query="insert into tb_file2(file_name,file_text,data)values('$file_name','$path','$data')";
	$result=mysql_query($query);
	if($result=true){ 
	echo "上傳成功!!";
	echo "<meta http-equiv=\"Refresh\" content=\"3;url=index.php?lmbs=文件上傳\">"; 
	}else{echo "文件上傳失敗!!";
          echo "<meta http-equiv=\"Refresh\" content=\"3;url=index.php?lmbs=文件上傳\">";}
}}}
?>
深圳北大青鳥(niǎo)嘉華校區(qū)http://m.sbsnmc.com
評(píng)論
熱點(diǎn)專(zhuān)題
>>
相關(guān)文章推薦
>>
好吊妞免费视频在线观看,久久亚洲国产人成综合网,久久精品国产2020,欧美精品综合在线
亚洲中文字幕5g在线 | 午夜性色福利剧场 | 亚洲AV秘一区二区色 | 亚洲人在线视频 | 日韩高清在线观看一二三区 | 在线观看亚洲欧美一区二区三区 |