|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
工具程序用来显示 Rasmus Lerdorf 的个人履历,以及统计网页流量。 PHP上传单张图片到办事器,以下代码:
- <?php session_start(); include("conn.php");?> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312"> <title>上传单图片到办事
器并显示 - www.cxybl.com</title> </head> <body> <table width="355" height="240" border="0" align="center" cellpadding="0" cellspacing="0"> <tr> <td width="106" height="100"> </td> <td width="196"> </td> <td width="31"> </td> </tr> <form name="form1" method="post" action="index_ok.php" enctype="multipart/form-data"> <tr> <td height="30" align="center"> </td> <td valign="middle"><input name="images" type="file" id="images2" size="15"> <input type="hidden" name="MAX_FILE_SIZE" value="30000"> </td> <td> </td> </tr> <tr> <td height="55"> </td> <td><input type="submit" name="Submit" value="提交"></td> <td> </td> </tr> </form> <tr> <td height="55"> </td> <td> </td> <td> </td> </tr> </table> <table width="355" border="1" align="center" cellpadding="0" cellspacing="0"> <?php $query="select * from tb_image2 where id order by data desc limit 2"; $result=mysql_query($query); if($result==true){ while($myrow=mysql_fetch_array($result)){ ?><tr> <td width="100" align="center"><?php echo $myrow[data];?></td> <td width="255" align="center"><img src="<?php echo $myrow[path];?>" width="200" height="150"></td> </tr> <?php }}?> </table> </body> </html>
复制代码 conn.php:
- <?php $id=mysql_connect('localhost','root','root'); mysql_select_db("db_database12",$id); mysql_query("set names gb2312"); ?>
复制代码 index_ok.php:
- <?php session_start(); include("conn.php");?> <?php if($Submit=="提交"){ $data=date("Y-m-d"); $filesize=$_FILES['images']['size']; if($filesize>1000000) {echo "<script> alert('对不起,您输出
的图片太大,不克不及
上传!!'); history.back();</script>";}else{ $path = 'upfiles/'. $_FILES['images']['name']; if (move_uploaded_file($_FILES['images']['tmp_name'],$path)) { $query1="insert into tb_image2(path,data,image_name)values('$path','$data','$images')"; $result1=mysql_query($query1); if($result1=true){ echo "上传胜利
!!"; echo "<meta http-equiv=\"Refresh\" content=\"3;url=index.php\">"; }else{echo "文件上传掉
败!!"; echo "<meta http-equiv=\"Refresh\" content=\"3;url=index.php\">";} }}} ?>
复制代码 如果不会怎么办,我的视频教程里有个最简单的留言板 最开始离不开模仿, |
|