




版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
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. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 知识产权管理软件的优化与升级策略探讨
- 集体股权合同范本
- 科技创新在环保产业的应用与挑战
- 科技助力商业模式的创新与升级
- 2025年河北石家庄建筑行业大型国有企业公开招聘46人笔试参考题库附带答案详解
- 2025至2030年中国胶带封箱机数据监测研究报告
- 电梯故障诊断技术及其在商业领域的应用
- 2025至2030年中国耐高温铁氟龙电线数据监测研究报告
- 二零二五年度解除劳动合同关系及经济补偿支付协议
- 二零二五年度服装厂员工绩效考核与晋升劳动合同
- 房屋租赁(出租)家私清单
- 仓储货架ppt课件
- 《保健按摩师》(五级)理论知识鉴定要素细目表
- 陈日新腧穴热敏化艾灸新疗法上篇
- 剪纸艺术-认识剪纸
- 驾驶员违规违章学习记录表
- PID烙铁恒温控制器设计与制作_图文
- wincc全套脚本总结
- 简易瞬态工况法1
- 中国铁路总公司环境保护管理办法(铁总计统〔2015〕260号)
- 医疗器械全生命周期风险管理
评论
0/150
提交评论