招生熱線
0755-86191118 0755-86191118
我的位置: 首頁 > 學習專區 > PHP技術 > php基礎教程:文件上傳

php基礎教程:文件上傳

2013-04-09 10:39:14
來源:
[導讀] php基礎教程:文件上傳conn.php

php基礎教程:文件上傳

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: 0px;
	margin-top: 00px;
	margin-right: 0px;
	margin-bottom: 0px;
}
-->
</style></head>
<script language="javascript">
function file1(form1){
 if(form1.file.value==""){
alert("上傳文件不能為空!!");
form1.file.focus();
return;}
form1.submit();}
</script>
<body>
<table width="462" height="162" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td width="140" height="68">&nbsp;</td>
    <td width="246">&nbsp;</td>
    <td width="69">&nbsp;</td>
  </tr>
  <form name="form1" method="post" action="index_ok.php">
  <tr>
    <td height="28">&nbsp;</td>
    <td align="left" valign="middle"><input name="file" type="file" size="22"></td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td height="30">&nbsp;</td>
    <td align="center" valign="top"><input type="submit" name="Submit" value="提交" 
     onClick="file1(form1);"></td>
    <td>&nbsp;</td>
  </tr>
  </form>
  <tr>
    <td height="36">&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
</table>
</body>
</html>

function.php:

<?php 
session_start();
include("conn.php");
       $data=date("Y-m-d");
       $file1="file_name1";
if($Submit==true){
    $query=mysql_query("insert into tb_file1 (file_name,file_text,data)values('$file1','$file','$data')");
if($query==true){
echo "文件上傳成功!!";
echo "<meta http-equiv=\"refresh\" content=\"3 url=index.php\">";
}else{
echo "上傳失敗!!";
echo "<meta http-equiv=\"refresh\" content=\"3 url=index.php\">";}}
?>
深圳北大青鳥嘉華校區http://www.sbsnmc.com
評論
相關文章
好吊妞免费视频在线观看,久久亚洲国产人成综合网,久久精品国产2020,欧美精品综合在线
日本中文字幕在线 | 亚洲一区二区三区体验区 | 天天看片国产区 | 亚洲国产第50页精品 | 思思热精品视频免费在线 | 中文字幕精品一区二区有码 |