php基礎(chǔ)教程-文件類_第1頁
php基礎(chǔ)教程-文件類_第2頁
php基礎(chǔ)教程-文件類_第3頁
php基礎(chǔ)教程-文件類_第4頁
php基礎(chǔ)教程-文件類_第5頁
已閱讀5頁,還剩4頁未讀, 繼續(xù)免費閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認領(lǐng)

文檔簡介

php基礎(chǔ)教程:文件類php基礎(chǔ)教程:文件上傳conn.php:<?php$id=mysql_connect('localhost','root','root');mysql_select_db("db_database12",$id);mysql_query("setnamesgb2312");?>index.php:<html><head><metahttp-equiv="Content-Type"content="text/html;charset=gb2312"><title>以二進制形式上傳文件到數(shù)據(jù)庫</title><styletype="text/css"><!--body{ margin-left:0px; margin-top:00px; margin-right:0px; margin-bottom:0px;}--></style></head><scriptlanguage="javascript">functionfile1(form1){if(form1.file.value==""){alert("上傳文件不能為空!!");form1.file.focus();return;}form1.submit();}</script><body><tablewidth="462"height="162"border="0"cellpadding="0"cellspacing="0"><tr><tdwidth="140"height="68"> </td><tdwidth="246"> </td><tdwidth="69"> </td></tr><formname="form1"method="post"action="index_ok.php"><tr><tdheight="28"> </td><tdalign="left"valign="middle"><inputname="file"type="file"size="22"></td><td> </td></tr><tr><tdheight="30"> </td><tdalign="center"valign="top"><inputtype="submit"name="Submit"value="提交"onClick="file1(form1);"></td><td> </td></tr></form><tr><tdheight="36"> </td><td> </td><td> </td></tr></table></body></html>function.php:<?phpsession_start();include("conn.php");$data=date("Y-m-d");$file1="file_name1";if($Submit==true){$query=mysql_query("insertintotb_file1(file_name,file_text,data)values('$file1','$file','$data')");if($query==true){echo"文件上傳成功!!";echo"<metahttp-equiv=\"refresh\"content=\"3url=index.php\">";}else{echo"上傳失敗!!";echo"<metahttp-equiv=\"refresh\"content=\"3url=index.php\">";}}?>php基礎(chǔ)教程:文件以二進制形式上傳并放入數(shù)據(jù)庫conn.php:<?php$id=mysql_connect('localhost','root','root');mysql_select_db("db_database12",$id);mysql_query("setnamesgb2312");?>index.php:<html><head><metahttp-equiv="Content-Type"content="text/html;charset=gb2312"><title>上傳文件到服務(wù)器</title><styletype="text/css"><!--body{ margin-left:00px; margin-top:0px; margin-right:0px; margin-bottom:0px;}--></style></head><body><tablewidth="385"height="185"border="0"cellpadding="0"cellspacing="0"><tr><tdwidth="130"height="85"> </td><tdwidth="200"> </td><tdwidth="55"> </td></tr><formname="form1"method="post"action="index_ok.php"enctype="multipart/form-data"><tr><tdheight="40"> </td><tdalign="center"valign="middle"><inputname="file2"type="file"id="file2"size="15"maxlength="150"></td><td> </td></tr><tr><tdheight="30"> </td><tdalign="center"><inputtype="submit"name="Submit"value="提交"></td><td> </td></tr></form><tr><tdheight="30"> </td><td> </td><td> </td></tr></table></body></html>index_ok.php:<?phpsession_start();include("conn.php");?><?phpif($Submit=="提交"){$data=date("Y-m-d");$file_name="file2";$path='./upfiles/'.$_FILES['file2']['name'];if(move_uploaded_file($_FILES['file2']['tmp_name'],$path)){ $query="insertintotb_file2(file_name,file_text,data)values('$file_name','$path','$data')"; $result=mysql_query($query); if($result=true){ echo"上傳成功!!"; echo"<metahttp-equiv=\"Refresh\"content=\"3;url=index.php?lmbs=文件上傳\">"; }else{echo"文件上傳失敗!!";echo"<metahttp-equiv=\"Refresh\"content=\"3;url=index.php?lmbs=文件上傳\">";}}}?>php基礎(chǔ)教程:把文件上傳到服務(wù)器conn.php:<?php$id=mysql_connect('localhost','root','root');mysql_select_db("db_database12",$id);mysql_query("setnamesgb2312");?>index.php:<html><head><metahttp-equiv="Content-Type"content="text/html;charset=gb2312"><title>限制大小的文件上傳</title><styletype="text/css"><!--body{ margin-left:00px; margin-top:0px; margin-right:0px; margin-bottom:0px;}--></style></head><body><tablewidth="385"height="185"border="0"cellpadding="0"cellspacing="0"background="image/316.JPG"><tr><tdwidth="130"height="75"> </td><tdwidth="200"> </td><tdwidth="55"> </td></tr><formname="form1"method="post"action="index_ok.php"enctype="multipart/form-data"><tr><tdheight="38"> </td><tdalign="center"valign="middle"><inputname="file3"type="file"id="file3"size="15"maxlength="150"></td><td> </td></tr><tr><tdheight="30"align="right"> </td><tdalign="center"valign="top"><inputtype="submit"name="Submit"value="提交">   </td><td> </td></tr></form><tr><tdheight="42"> </td><td> </td><td> </td></tr></table></body></html>index_ok.php:<?phpsession_start();include("conn.php");?><?phpif($Submit=="提交"){$data=date("Y-m-d");$file_name="files";$filesize=$_FILES['file3']['size'];if($filesize>2000000){echo"對不起,您上傳的文件超過了規(guī)定的大小!!";echo"<metahttp-equiv=\"Refresh\"content=\"3;url=index.php?lmbs=文件上傳\">將在3秒鐘后返回前頁...";}else{$path='./upfiles/'.$_FILES['file3']['name'];if(move_uploaded_file($_FILES['file3']['tmp_name'],$path)){ $query="insertintotb_file2(file_name,file_text,data)values('$file_name','$path','$data')"; $result=mysql_query($query); if($result=true){ echo"上傳成功!!"; echo"<metahttp-equiv=\"Refresh\"content=\"3;url=index.php?lmbs=文件上傳\">"; }else{echo"文件上傳失敗!!";echo"<metahttp-equiv=\"Refresh\"content=\"3;url=index.php?lmbs=文件上傳\">";}}}}?>php基礎(chǔ)教程:限制大小的文件上傳conn.php:<?php$id=mysql_connect('localhost','root','root');mysql_select_db("db_database12",$id);mysql_query("setnamesgb2312");?>index.php:<html><head><metahttp-equiv="Content-Type"content="text/html;charset=gb2312"><title>限制大小的文件上傳</title><styletype="text/css"><!--body{ margin-left:00px; margin-top:0px; margin-right:0px; margin-bottom:0px;}--></style></head><body><tablewidth="385"height="185"border="0"cellpadding="0"cellspacing="0"><tr><tdwidth="130"height="75"> </td><tdwidth="200"> </td><tdwidth="55"> </td></tr><formname="form1"method="post"action="index_ok.php"enctype="multipart/form-data"><tr><tdheight="38"> </td><tdalign="center"valign="middle"><inputname="file3"type="file"id="file3"size="15"maxlength="150"></td><td> </td></tr><tr><tdheight="30"align="right"> </td><tdalign="center"valign="top"><inputtype="submit"name="Submit"value="提交">   </td><td> </td></tr></form><tr><tdheight="42"> </td><td> </td><td> </td></tr></table></body></html>index_ok.php:<?phpsession_star

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論