ªð¦^¦Cªí ¤W¤@¥DÃD µo©«

[±Ð¾Ç] ÀɮפW¶Ç

[±Ð¾Ç] ÀɮפW¶Ç

¦bPHPªº¥@¬É¤¤¡AÀɮפW¶Ç¤w¤£¬O¥ó§xÃøªº¨ÆÅo¡I¦ý½Ð±z¤d¸U°O±o¤@¥ó¨Æ¡Gªí³æªº¸ê®Æ½s½X«¬ºA¡]EncType¡^¤@©w­n³]¬°¡yMultipart/Form-data¡z¡C


¦bªí³æÄæ¦ì¤¸¥ó¤¤¦³¤@­Ó¦W¬°¡uFile¡vªº¤¸¥ó¡A¥¦¬O¥Ñ¡uText¡v¤å¦rÄæ¦ì»P¡uButton¡v©Ò²Õ¦¨¡A·í§Ú­Ì«ö¤U¡uÂsÄý¡v«ö¶s®É¡A´N·|¥X²{¡u¿ï¾ÜÀɮסvµøµ¡Åý§Ú­Ì¿ï¨ú¥»¾÷¤¤ªºÀɮסA¨Ò¦p¡G



³o­Ó¡uFile¡vÄæ¦ì¤¸¥ó´N¬O¥D¨¤¤§¤@¡A¦b¡u¿ï¾ÜÀɮסv¥«µ¡¤¤¥X²{ªºÀÉ®×»P¥Ø¸ô³£¬O¨Ï¥ÎªÌºÝ¾÷¾¹ªº¤º®e¡A¦Ó«D§Ú­Ìªº¦øªA¾¹Àɮפº®e³á¡I¼o¸Ü¤£¦h»¡¡A§Ú­Ì¥ý¨Ó§¹¦¨°ò¦ªº¤W¶Çºô­¶¤Îªí³æ¤¸¥ó§G¸m¡A§¹¦¨µe­±¦p¤U¹Ï¡G



uploadn.php
  1. <HTML><BODY>
  2. <H3>FTP ÀɮפW¶Ç:(¶Ç°e³æ­ÓÀÉ®×)<HR></H3>

  3. <Form Action="mygetfilen.php" Method="POST"
  4. Enctype="multipart/form-data">
  5. <Input Type="File" Name="upfile" ><br>
  6. <Input Type="Submit" value=" ¶}©l¤W¶Ç ">
  7. </Form>

  8. </BODY></HTM>
½Æ»s¥N½X
¯u¥¿³B²zÀɮפW¶Ç¤u§@ªº¬O¡umygetfilen.php¡v¦Ó«D¤W¶Çªí³æ¡uuploadn.php¡v¡G

mygetfilen.php
  1. <HTML>
  2. <head>
  3. <meta http-equiv="Content-Type" content="text/html; charset=big5">
  4. <title>³æÀɮפW¶Ç</title>
  5. </head>
  6. <BODY><H3>¤W¶ÇÀɮ׬ÛÃö¸ê°T¡G<HR></H3>

  7. <?
  8.       echo "<BLOCKQUOTE>";
  9.       echo "ÀɮצWºÙ¡G" . $_FILES["upfile"]["name"] . "<BR>";
  10.       echo "Àɮפj¤p¡G" . $_FILES["upfile"]["size"] . "<BR>";
  11.       echo "ÀÉ®×Ãþ«¬¡G" . $_FILES["upfile"]["type"] . "<BR>";
  12.       echo "¼È¦sÀɦW¡G" . $_FILES["upfile"]["tmp_name"] . "<BR>";
  13.             move_uploaded_file($_FILES["upfile"]["tmp_name"], "file\\" . $_FILES["upfile"]["name"]);
  14.          echo "±z©Ò¤W¶ÇªºÀɮפwÀx¦s¬° " . $_FILES["upfile"]["name"];
  15.       echo "</BLOCKQUOTE>";
  16. ?>

  17. <HR></BODY></HTML>
½Æ»s¥N½X
¤ß¦w¡A¥­¦w   
µoªí¥ô¦óµL·N¸qªº·PÁ©ÎÄé¤ô¤å³¹¤@«ß¬å,¬Ã±¤±b¸¹,½Ð¸Ô¾\ª©³W!!

­n¨ú±oÀɮ׬ÛÃö¸ê°T¡A¥²¶·§Q¥Î¡u$_FILES¡vÅܼư}¦C¡G
  1. $_FILE[ªí³æ¤¤ªºFILEÄæ¦ì¤¸¥ó¦W][¤W¶ÇªºÀÉ®×ÄÝ©Ê]
½Æ»s¥N½X
¤W¶ÇªºÀÉ®×Äݩʦ³¤U¦C¼ÆºØ¡G

  • name¡G¤W¶ÇÀɮתº­ì©l¦WºÙ¡C
  • size¡G¤W¶ÇÀɮתºªÅ¶¡¤j¤p¡]Àɮפj¤p¡^¡C
  • type¡G¤W¶ÇÀɮתº¸ê®ÆÃþ«¬¡C
  • tmp_name¡GPHPµ{¦¡±µ¦¬¤W¶ÇÀɮ׫á¡A¥¼¤W¶ÇÀɮשҭq©wªº¼È®É¦WºÙ¡C




move_upload_file()¨ç¼Æ¡G
  1. bool move_uploaded_file ( string filename, string destination)
½Æ»s¥N½X
¦]¬°ÀɮפW¶Ç«á¡A¸ÓÀÉ®×±N³Q©ñ¦Ü©ó¼È¦s¥Ø¿ý¤¤¡A·íµ{¦¡°õ¦æ§¹²¦«á¡A³o­Ó¤W¶ÇÀÉ®×±N·|³Q§R°£¡A¦]¦¹¡A¥²¶·¨Ï¥Îmove_upload_file()¨ç¼Æ±N¦¹¤W¶ÇÀɲ¾¨ì§Ú­Ì«ü©wªº¦s©ñ¦ì¸m¥h¡C

¤W¶ÇÀɮתº¦s©ñ¦ì¸m¡A¤]´N¬O©ñ¸m¤W¶ÇÀɮתº¥Ø¿ý¸ê®Æ§¨¡A¨ä¼g¤JªºÅv­­¥²¶·¥´¶}¡A³o¼Ëmove_upload_file()¨ç¼Æ¤~¯à¶¶§Q±N¦¹¤W¶ÇÀɲ¾¨ì§Ú­Ì«ü©wªº¦s©ñ¦ì¸m¥h¡C




¯S§O¤p¤ß¡G¦pªG¤W¶ÇÀɮתº¤j¤p¬O0¡A«hmove_upload_file()¨ç¼Æ¦b·h²¾¼È¦sÀɨì«ü©w¦ì¸m®É±N·|²£¥Í¿ù»~¡A©Ò¥H¦bmove_upload_file()¨ç¼Æ°õ¦æ¤§«e¡A¡A§Ú­ÌÀ³¸Ó³z¹LÀɮפj¤pªºÀËÅç¨Ó¹w¨¾¿ù»~¡G½d¨Òmygetfilen2.php
  1. <HTML>
  2. <head>
  3. <meta http-equiv="Content-Type" content="text/html; charset=big5">
  4. <title>³æÀɮפW¶Ç</title>
  5. </head>
  6. <BODY><H3>¤W¶ÇÀɮ׬ÛÃö¸ê°T¡G<HR></H3>

  7. <?
  8.       echo "<BLOCKQUOTE>";
  9.       echo "ÀɮצWºÙ¡G" . $_FILES["upfile"]["name"] . "<BR>";
  10.       echo "Àɮפj¤p¡G" . $_FILES["upfile"]["size"] . "<BR>";
  11.       echo "ÀÉ®×Ãþ«¬¡G" . $_FILES["upfile"]["type"] . "<BR>";
  12.       echo "¼È¦sÀɦW¡G" . $_FILES["upfile"]["tmp_name"] . "<BR>";
  13.      //ÀËÅçÀɮפj¤p¬O§_¤j©ó0
  14.      if ( $_FILES["upfile"]["size"] > 0 )
  15.       {
  16.          move_uploaded_file($_FILES["upfile"]["tmp_name"], "file\\" . $_FILES["upfile"]["name"]);
  17.          echo "±z©Ò¤W¶ÇªºÀɮפwÀx¦s¬° " . $_FILES["upfile"]["name"];
  18.       }
  19.      else
  20.       {
  21.         echo "¤W¶ÇÀɮ׿ù»~!±z¶Ç°eªº¬OªÅÀÉ®×!!";
  22.       }
  23.       echo "</BLOCKQUOTE>";
  24. ?>

  25. <HR></BODY></HTML>
½Æ»s¥N½X
°£¤FÀɮפj¤p¤£¯à¬°0¥~¡A§Ú­Ì¤]À³¸Ó­­¨î¤W¶ÇÀɮתº³Ì¤jÅé¿n¡A§K±o§Ú­Ìªº¦øªA¾¹³Q¤j«¬ªºÀÉ®×µ¹¶ë¼É¤F¡I
  1. //ÀËÅçÀɮפj¤p¬O§_¤j©ó0
  2.      if ( $_FILES["upfile"]["size"] <= 0)
  3.       {
  4.          echo "¤W¶ÇÀɮ׿ù»~!±z¶Ç°eªº¬OªÅÀÉ®×!!";
  5.       }
  6.      //ÀËÅçÀÉ®×Åé¿n¬O§_¹L¤j
  7.      else if ( $_FILES["upfile"]["size"] > 50000)
  8.       {
  9.          echo "¤W¶ÇÀɮ׿ù»~!±z¶Ç°eªºÀɮפj©ó50k!!";
  10.       }
  11.      else
  12.       {
  13.         move_uploaded_file($_FILES["upfile"]["tmp_name"], "file\\" . $_FILES["upfile"]["name"]);
  14.          echo "±z©Ò¤W¶ÇªºÀɮפwÀx¦s¬° " . $_FILES["upfile"]["name"];
  15.       }
½Æ»s¥N½X
¤ß¦w¡A¥­¦w   
µoªí¥ô¦óµL·N¸qªº·PÁ©ÎÄé¤ô¤å³¹¤@«ß¬å,¬Ã±¤±b¸¹,½Ð¸Ô¾\ª©³W!!

TOP

¤W¶ÇÀɮ׬ÛÃö¸ê°T¡G
--------------------------------------------------------------------------------

ÀɮצWºÙ¡Grammus.png
Àɮפj¤p¡G1169872
ÀÉ®×Ãþ«¬¡Gimage/x-png
¼È¦sÀɦW¡GC:\Windows\Temp\phpE6DF.tmp

Warning: move_uploaded_file(file\rammus.png) [function.move-uploaded-file]: failed to open stream: No such file or directory in C:\AppServ\www\upload\mygetfilen.php on line 14

Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move 'C:\Windows\Temp\phpE6DF.tmp' to 'file\rammus.png' in C:\AppServ\www\upload\mygetfilen.php on line 14
±z©Ò¤W¶ÇªºÀɮפwÀx¦s¬° rammus.png

TOP

¤W­±ªº¬O¨Ï¥Î¤FAPPSERV¡A¦ý§Ú¥Î¤F§K¶OªÅ¶¡¸Õ¤S¨S¦³°ÝÃD
¤W¶ÇÀɮ׬ÛÃö¸ê°T¡G
--------------------------------------------------------------------------------

ÀɮצWºÙ¡Grammus.png
Àɮפj¤p¡G1169872
ÀÉ®×Ãþ«¬¡Gimage/x-png
¼È¦sÀɦW¡G/tmp/phphn0TaV
±z©Ò¤W¶ÇªºÀɮפwÀx¦s¬° rammus.png
--------------------------------------------------------------------------------


¥i¬O§Ú§ä¤£¨ì¤W¸ü¤Fªº¤å¥ó...

TOP

        ÀR«ä¦Û¦b : ¸Ü¦h¤£¦p¸Ü¤Ö¡A¸Ü¤Ö¤£¦p¸Ü¦n¡C
ªð¦^¦Cªí ¤W¤@¥DÃD