如何在上传文件之前或之后重命名文件?我只想重命名文件名,而不是扩展名.
$changeTXT = $_SESSION['username']; $uploaderName = strtolower($changeTXT); $changeTXT = strtolower($changeTXT); $changeTXT = ucfirst($changeTXT); $filelocation = $_POST['userfile']; $filename = $_POST['filename']; $max_size = $_POST['MAX_FILE_SIZE']; $file = $_FILES['userfile']; $allowedExtensions = array("wma","mp3","wav"); function isAllowedExtension($fileName) { global $allowedExtensions; return in_array(end(explode(".",$fileName)),$allowedExtensions); } if($file['error'] == UPLOAD_ERR_OK) { if(isAllowedExtension($file['name'])) { $uploaddir = "uploads/".$uploaderName."/"; $uploadfile = $uploaddir . basename($_FILES['userfile']['name']); if (move_uploaded_file($_FILES['userfile']['tmp_name'],$uploadfile)) { echo "Thank you for uploading your music!<br /><br />"; } else { echo "Your file did not upload.<br /><br />"; } echo "\n"; echo "<a href='index.PHP'>Return</a> to index.<br /><br />$uploaddir"; } else { echo "You have tried to upload an invalid file type.<br /><br />"; } } else die("Cannot upload");