就是用户上传照片,建一个相册1

解决方案 »

  1.   

    img.htm   
      --------   
      <html>   
      <head>   
      <title>图片提交</title>   
      <meta   http-equiv="Content-Type"   content="text/html;   charset=gb2312">   
      </head>   
        
      <body   bgcolor="#FFFFFF"   text="#000000">   
      <form   name="form"   method="post"   action="imgcun.php">   
          <table   width="150"   border="1"   align="center"   bordercolor="#0099FF">   
              <tr>     
                  <td   height="30">     
                      <input   type="file"   name="img"   size="40">   
                  </td>   
              </tr>   
              <tr>     
                  <td   height="54">     
                      <textarea   name="img_jj"   cols="50"   rows="5"></textarea>   
                  </td>   
              </tr>   
              <tr>     
                  <td>     
                      <div   align="center">   
                          <input   type="submit"   name="Submit"   value="提交">   
                      </div>   
                  </td>   
              </tr>   
          </table>   
      </form>   
      <p   align="center"><a   href="imgshow.php">图片展示</a></p>   
      </body>   
      </html>   
        
        
        
        
        
        
        
      imgcun.php   
      ----------   
      <?   
      if($img=="")   
      {   
      echo"文件没有上传!";   
      exit;   
      }   
        
      $wen=time().".jpg";   
        
        
      if(copy($img,$wen))   
      {   
      echo"上传成功";   
      $link=mysql_connect("localhost","root");   
      mysql_select_db("wdn",$link);   
      $query="insert   into   img(img,img_jj)   values('$wen','$img_jj')";   
      if(mysql_query($query))   
      {   
      echo"<br>";   
      echo   "数据存储成功";   
      echo"<br>";   
      echo   "<img   src='".$wen."'>";   
      }   
      }   
      ?>   
        
        
        
      imgshow.php   
      -------------   
      <html>   
      <head>   
      <title>图片展示</title>   
      <meta   http-equiv="Content-Type"   content="text/html;   charset=gb2312">   
      </head>   
      <body   bgcolor="#FFFFFF"   text="#000000">   
        
      <?   
      $link=mysql_connect("localhost","root");   
      mysql_select_db("wdn");   
      $pd=mysql_query('select   *   from   img',$link);   
      $i=0;   
        
      echo"<table   width='700'   border='0'   cellspacing='20'>";   
      echo"<tr>";   
        
      while($array=mysql_fetch_array($pd))   
        {   
      $i++;   
      echo"<td   width='150'>   ";   
      echo"<table   width='150'   border='1'   bordercolor='#0099FF'>";   
      echo"<tr>";   
      echo"<td   width='150'><font   size='2'><a   href='".$array[img]."'><img   src='".$array[img]."'   width='150'   border='0'   alt='ID:".$array[img]."'   ></a></font></td>";   
                      echo"</tr>";   
                      echo"<tr>   ";   
                      echo"<td   width='150'><font   size='2'>图片简介:".$array[img_jj]."</font></td>";   
                      echo"</tr>";   
      echo"</table>";   
      echo"</td>";   
      if($i%4=="0")   
      {   
      echo"</tr>";   
      }   
      }   
      echo"</table>";   
      ?>   
      </body>   
      </html>   
        
        
        
        
      数据库:   
      ------   
      CREATE   TABLE   img   (   
          img   varchar(15)   default   NULL,   
          img_jj   varchar(100)   default   NULL   
      )   TYPE=MyISAM;   http://topic.csdn.net/t/20020518/02/731921.html