Maison > Article > développement back-end > php的move_uploaded_file一直返回false
phpfilemove
<code> <form action="?action=save&type=image&style=boolblue&language=zh-cn" method="post" name="myform" enctype="multipart/form-data"> <input type="hidden" name="MAX_FILE_SIZE" value="width:100%"> <input type="file" name="uploadfile" size="1" style="width:100%"> </form> <?phpfunction DoSave(){ if($_FILES['uploadfile']['error'] != UPLOAD_ERR_OK){ switch((int)$_FILES['uploadfile']['error']){ case UPLOAD_ERR_NO_FILE: OutScript("parent.UploadError('lang[\"ErrUploadInvalidFile\"]')"); break; case UPLOAD_ERR_FORM_SIZE: OutScript("parent.UploadError('lang[\"ErrUploadSizeLimit\"]+\":".$GLOBALS["nAllowSize"]."KB\"')"); break; } exit; } preg_match("/\.([a-zA-Z0-9]{2,4})$/",$_FILES['uploadfile']['name'],$exts); CheckValidExt($exts[1]); $GLOBALS["sSaveFileName"] = GetRndFileName(strtolower($exts[1])); $GLOBALS["sOriginalFileName"] = $_FILES['uploadfile']['name']; $sFileName = str_replace('\\','\\\\',realpath($GLOBALS["sUploadDir"]))."/"; $sFileName .= $GLOBALS["sSaveFileName"]; if(!move_uploaded_file($_FILES["uploadfile"]["tmp_name"],$sFileName)){ OutScript("parent.UploadError('Error')");到这就退出了 exit; } 。。。。。。。 ?></code>