PHP文件创建、复制、移动、删除文件

html代码如下:

  1. <html>
  2. <head>
  3. <meta http-equiv="content-type" content="text/html; charset=gb2312">
  4. <title>创建、复制、移动、删除文件</title>
  5. <style type="text/css教程">
  6. <!--
  7. body {
  8. margin-left: 00px;
  9. margin-top: 0px;
  10. margin-right: 0px;
  11. margin-bottom: 0px;
  12. }
  13. -->
  14. </style></head>
  15. <body>
  16. <table width="350" cellpadding="0" cellspacing="0">
  17. <tr>
  18. <td><table width="350" height="80" cellpadding="0" cellspacing="0" background="images/326ssss.gif">
  19. <form name="form1" method="post" action="index.php教程">
  20. <tr>
  21. <td width="95" height="39"> </td>
  22. <td width="171" rowspan="2" align="left" valign="middle"> <input name="fopens" type="text" size="22"></td>
  23. <td width="84" rowspan="2" valign="middle"><input name="submit4" type="submit" value="提交"></td>
  24. </tr>
  25. <tr>
  26. <td height="41"> </td>
  27. </tr>
  28. </form>
  29. </table></td>
  30. </tr>
  31. <tr>
  32. <td><table width="350" height="80" cellpadding="0" cellspacing="0" background="images/326s.gif">
  33. <form name="form1" method="post" action="index.php">
  34. <tr>
  35. <td width="111" height="39"> </td>
  36. <td width="155" valign="bottom"><input name="copys" type="text" size="20">
  37. </td>
  38. <td width="84" rowspan="2" valign="middle"><input type="submit" name="submit" value="提交"></td>
  39. </tr>
  40. <tr>
  41. <td height="41"> </td>
  42. <td valign="top"><input name="copy2" type="text" size="20"></td>
  43. </tr>
  44. </form>
  45. </table></td>
  46. </tr>
  47. <tr>
  48. <td><table width="350" height="80" cellpadding="0" cellspacing="0" background="images/326ss.gif">
  49. <form name="form1" method="post" action="index.php">
  50. <tr>
  51. <td width="111" height="39"> </td>
  52. <td width="115" valign="bottom"><input name="moves" type="text" size="20">
  53. </td>
  54. <td width="84" rowspan="2"><input type="submit" name="submit2" value="提交"></td>
  55. </tr>
  56. <tr>
  57. <td height="41"> </td>
  58. <td valign="top"><input name="moves2" type="text" size="20"></td>
  59. </tr>
  60. </form>
  61. </table></td>
  62. </tr>
  63. <tr>
  64. <td><table width="350" height="80" cellpadding="0" cellspacing="0" background="images/326sss.gif">
  65. <form name="form1" method="post" action="index.php">
  66. <tr>
  67. <td width="104"> </td>
  68. <td width="236"><input name="delete" type="text" >
  69. <input type="submit" name="submit3" value="提交"></td>
  70. </tr>
  71. </form>
  72. </table></td>
  73. </tr>
  74. </table>
  75. </body>
  76. </html>

php代码如下:

  1. <?php session_start();
  2. if($submit=="提交"){
  3. $copy=$_post[copys];
  4. $copys2=$_post[copy2];
  5. if(copy($copy,$copys2)==true){echo "复制成功!!";}else{echo "失败!!";};
  6. }
  7. if($submit2=="提交"){
  8. $moves=$_post[moves];
  9. $moves2=$_post[moves2];
  10. if(rename($moves,$moves2)==true){echo "移动成功!!";}else{echo "失败!!";};
  11. }
  12. if($submit3=="提交"){
  13. $delete=$_post[delete];
  14. if(unlink($delete)==true){echo "删除成功!!";}else{echo "失败!!";};
  15. }
  16. if($submit4=="提交"){
  17. $fopens=$_post[fopens];
  18. if(fopen($fopens,"w")==true){echo "创建成功!!";}else{echo "失败!!";};
  19. }
  20. //开源代码phpfensi.com
  21. ?>