±¾ÎÄʵÀý½²ÊoÁËPHPÎļþÉÏ´«´¦ÀiµÄ½¨¡£*ÖÏi¸ø´o¼Ò¹(C)´o¼Ò²Î¿¼£¬¾ßÌaÈçÏ£º
×i½uÓoµ½Ò»¸oÊ£¬°Ñ×Ô¼º¿ÓÁ˺þã¬ÎÒÏe˵˵ÎÒ¿ªÊ¼µÄÏe*¨
PHPµÄÉÏ´«»uÖÆ*a×°µÄºÜÍeÈ«£¬»u±¾¼¸ÐдuÂe¾ÍÄÜʵÏÖ£¬ËuµÄʵÏÖÁ÷³ÌÊÇÕaÑuµÄ
UPLOADµ½Îļþµ½ÁÙʱĿ¼ÖШC>ʹÓÃmove_uploadde_file()µ½Ö¸¶¨µÄĿ¼
Õa¾ÍÊÇPHPÉÏ´«Á÷³Ì£¬»oÕßÄaÔÚÖÐ;ÔÙ½øÐÐÒ»Ð(C)ÑeÖ¤¡£ÀýÈçÅжÏÊDz»ÊÇͨ¹ýupload*½Ê½Ìa½»µÄÎĵµ£¬»oÕßÎļþµÄÀ(C)Õ¹ÊDz»ÊÇÎÒÃÇÔÊÐiµÄ
µÈµÈһϵÁÐÑeÖ¤¡£ÎÒ¸ø³o¼oµ¥µÄ´uÂeÒ²ËaÊÇÅ××(C)ÒýÓñÁË¡£
$targetFolder = '/uploads'; // ¶¨Òa¸uĿ¼
if (!empty($_FILES)) {
$tempFile = $_FILES['Filedata']['tmp_name'];
if(is_uploaded_file($tempFile))
{
$targetPath = $_SERVER['DOCUMENT_ROOT'] . $targetFolder;
$targetFile = rtrim($targetPath,'/') . '/' . $_FILES['Filedata']['name'];
$fileTypes = array('jpg','jpeg','gif','png'); // ÔÊÐiµÄºo׺À(C)Õ¹
$fileParts = pathinfo($_FILES['Filedata']['name']);
if (in_array($fileParts['extension'],$fileTypes)) {
move_uploaded_file($tempFile,$targetFile);
echo '1';
} else {
echo '*Ç*¨ÉÏ´«Îĵµ.';
}
}else
{
echo "*Ç*¨ÉÏ´«Îļþ";
}
}
ÉÏÃaeµÄÕaÖÖ*½Ê½»u±¾¾ÍÂu×aÁËÎļþÉÏ´«¡£µ«ÎÒÐeÒªµÄ²»ÊÇÕaÑuµÄ¡£
ÉÏ´«¹¦ÄÜ
ÐeÇo£ºÏȵa»÷ÉÏ´«Îĵµ£¬È»ºoÑ¡ÔñÉÏ´«Îļþ£¬JSÉÏ´«ºo»a*µ»ØÒ»¸oÖµ£¬ÏÔʾµ±Ç°Ê±¼a´ÁÎÊÃu³ÆµÄÎļþÔÚÎĵµÃu³ÆÕa¸o¿o¿oÖС£
È»ºoµa»÷Ìa½»ºo£¬Ìa½»±iµ¥¡£
*þÎñÆ÷´¦ÀiÌa½»µÄ±iµ¥£¬¶ÔÉÏ´«µÄÎļþ½øÐÐÖØÃuÃu¡£
ÎÊÌaÒ²ËaeÖ®¶øÀ´ÁË£¬þÎñÆ÷ÊÇIISµÄ£¬È»ºoËuÊÇÓõÄÓ³ÉaµÄ½Ê½ÊµÏÖµÄÐeÄa¸uĿ¼¡£
ÕaÑuµÄ»°$_SERVER[¡®DOCUMENT_ROOT']¾Í²»ÔÚPHPÕ¾µaµÄ¸uĿ¼
ËaÈ»Íe³ÉÁËÉÏ´«µÄ¹¦ÄÜ£¬µ«ÎÞ¨ÏÂÔØÕa¸oÎļþ¡£´ÓþÎñÆ÷µÄ°²È«¿¼ÂÇ£¬»¹ÊÇ´oËa°ÑÎļþ*ÅÔÚPHPÕ¾µaÄÚ¡£
È»ºoÎÒ¾ÍÏݽøÁËÒ»¸o˼ά¾ÖÏÞÖС£
ÔÙ×ÐϸÏeÒ»Ïe£º
ΪºÎÎÒ²»ÓÃʵÏÖPHPµÄÉÏ´«»uÖƵÄ*½Ê½ÔÚÖظ´Ò»´Î¡£
PHP²»Êǽ«ÎļþÏÈ*ŵ½ÁÙʱĿ¼ÀiÃaeÂð£¿È»ºoÎÒΪÂi¼ÙÉeJSÉÏ´«³É¹¦ºoµÄĿ¼ҲÊÇÒ»¸oÁÙʱĿ¼£¬
È»ºoÔÚÔÙÒ»´ÎÌa½»±iµ¥µÄʱºo½øÐÐÎļþ¸´ÖÆ¡£µ½Ö¸¶¨µÄĿ¼ÕaÑu¾ÍÍe³ÉÁËÐeÒªµÄ¹¦ÄÜ¡£
PHPÓÐÒ»¸oÎļþ¸´Öƺ¯ÊýCopy(); È»ºoÔÚÅaºÏrename()º¯Êý¡£ÕaÑu¾Í¿ÉÒÔÍe³ÉÉÏ´«ºoÎļþµÄµÚ¶þ´ÎÒƶ¯ºÍÖØÃuÃuÁË¡£
×¢Òa£ºÔÚwindowƽ̨ÏÂÈç¹u¸´ÖÆÒ»¸oÁa×Ö½ÚµÄÎļþ£¬copy() ½«µ»Ø FALSE £¬µ«ÎļþÒ²»a±»Õýȸ´ÖÆ¡£
È»ºoPHPÔÚÎļþ´¦ÀiÉÏ£¬»ý¼«µÄ²Î¿¼ÁËLiunxµÄÎļþ´¦Ài»uÖÆ¡£PHPµÄÎļþ²Ù×÷ЧÂÊ£¬Õa¸uI/O¶ÔдºÍ²Ù×÷ϵͳÓйء£
×ܽa£ºÆaʵ½a¾oÎÊÌaµÄ*½Ê½ºÜ¶a£¬¶øÇÒ²»Òª¸ø×Ô¼º»È¦´Ó¶øÏÞ¶¨×Ô¼ºµÄ˼ά¡£
¸u¶a¹ØÓÚPHPÏa¹ØÄÚÈݸÐÐËȤµÄ¶ÁÕ߿ɲe¿´±¾Õ¾×¨Ìa£º¡¶phpÎļþ²Ù×÷×ܽa¡¡¢¡¶PHPͼÐÎÓeͼƬ²Ù×÷¼¼ÇÉ»a×Ü¡¡¢¡¶PHPÊý×e(Array)²Ù×÷¼¼ÇÉ´oÈ«¡¡¢¡¶[PHP»u±¾Ói¨ÈeÃŽ̳Ì](http://www.jb51.net/Special/348.htm)¡¡¢¡¶[PHPÔËËaÓeÔËËauÓè×ܽa](http://www.jb51.net/Special/357.htm)¡¡¢¡¶phpÃaeÏo¶ÔÏo³ÌÐoÉe¼ÆÈeÃŽ̡̳¡¢¡¶PHPÍøÂç±a³Ì¼¼ÇÉ×ܽa¡¡¢¡¶php×Öu´®(string)Óè×ܽa¡¡¢¡¶php+mysqlÊý¾Ý¿a²Ù×÷ÈeÃŽ̡̳¼°¡¶php³£¼uÊý¾Ý¿a²Ù×÷¼¼ÇÉ»a×Ü¡*
Ï£Íu±¾ÎÄËuÊo¶Ô´o¼ÒPHP³ÌÐoÉe¼ÆÓÐËu°iÖu¡£