版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
php基础教程:文件类php基础教程:文件上传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: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基础教程:文件以二进制形式上传并放入数据库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="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基础教程:把文件上传到服务器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"对不起,您上传的文件超过了规定的大小!!";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基础教程:限制大小的文件上传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. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 汽轮机调速系统特性深度剖析与精准模型辨识研究
- 汽车车身造型与外围流场CFD相关性的深度剖析与实践应用
- 汽车排放测量技术与方法:原理、应用及未来发展
- 教科版四年级科学下册期中综合素养测试卷
- 商品房买卖独家委托协议
- 唱片制作发行工程师考试试卷及答案
- 2026年家校沟通技巧考试真题及答案
- 退货物流管理规定
- 农村污水管网检查井设置规范及要求
- 2025年会诊制度考试真题及答案
- 5.3民族区域自治制度 课件 2025-2026学年统编版道德与法治八年级下册
- 金融公司档案管理制度(标准范本)
- 高速公路服务区光伏发电施工方案
- 2026北京中牧实业股份有限公司高校毕业生招聘21人备考笔试题库及答案解析
- 直燃机维修协议书
- 抖音本地生活服务推广与运营策略
- 《交易心理分析》中文
- 2026年金融风控人工智能应用方案
- 防溺水安全教育小班课件
- 海南锋利气体有限公司空分设备更新及配套项目环境影响报告表
- 神经科颅内感染治疗规范
评论
0/150
提交评论