版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
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. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2026年社会工作(社区建设)试题及答案
- 2025年大学小学教育(小学教育应用)试题及答案
- 2025年中职安全(危险预判)试题及答案
- 2025年中职口腔技术(口腔修复体就位)试题及答案
- 2025年中职(眼视光与配镜)视力矫正技能测试题及答案
- 2026年隐私计算安全融合项目营销方案
- 2025年中职针灸推拿(推拿手法)试题及答案
- 2026年湿电子化学品项目评估报告
- 2025年高职(环境监测技术)清洁生产技术试题及答案
- 2025年高职(医疗器械维护与管理)医疗器械检测试题及答案
- 杭州余杭水务有限公司2025年度公开招聘备考题库附答案详解
- 鹿邑县2025年事业单位引进高层次人才备考题库及答案详解(新)
- 2025云南昆明巫家坝城市发展建设有限公司社会招聘14人笔试历年难易错考点试卷带答案解析
- 医院科室文化建设与礼仪
- 2025年大学(直播电商实训)管理实操试题及答案
- 医院重症医学科主任谈重症医学治疗
- 云南省2025年普通高中学业水平合格性考试地理试题
- 2025贵州磷化(集团)有限责任公司12月招聘笔试参考题库及答案解析
- 基础土方回填施工工艺方案
- 征信修复合同范本
- 2025年苏州工业园区领军创业投资有限公司招聘备考题库及一套答案详解
评论
0/150
提交评论