Php 感谢登录用户上传文件
我需要用大写字母感谢用户的名字Php 感谢登录用户上传文件,php,file,upload,Php,File,Upload,我需要用大写字母感谢用户的名字 if (move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], $target_file)) { echo "Thank You, {$_SERVER['PHP_AUTH_USER']}. The file ". basename( $_FILES["fileToUpload"]["name"]). " has been uploaded."; 上面的代码有效。我试过这个: if (move
if (move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], $target_file)) {
echo "Thank You, {$_SERVER['PHP_AUTH_USER']}. The file ". basename( $_FILES["fileToUpload"]["name"]). " has been uploaded.";
上面的代码有效。我试过这个:
if (move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], $target_file)) {
echo "Thank You, ucfirst({$_SERVER['PHP_AUTH_USER']}). The file ". basename( $_FILES["fileToUpload"]["name"]). " has been uploaded.";
但这只是输出。如能在此格式中帮助用户将姓名大写,将不胜感激
编辑
在Tim发表评论后,我尝试将此应用于其他可能的消息,但由于某些原因,这不起作用,我也不知道为什么
if (file_exists($target_file)) {
echo " Sorry ".ucfirst($_SERVER['PHP_AUTH_USER']).", the file already exists. Please try renaming or adding a version number.";
$uploadOk = 0;
}
// Check if $uploadOk is set to 0 by an error
if ($uploadOk == 0) {
echo " Sorry ".ucfirst($_SERVER['PHP_AUTH_USER']).", your file was not uploaded.";
// if everything is ok, try to upload file
} else {
if (move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], $target_file)) {
echo "Thank You, ".ucfirst($_SERVER['PHP_AUTH_USER']).". The file ". basename( $_FILES["fileToUpload"]["name"]). " has been uploaded.";
} else {
echo " Sorry ".ucfirst($_SERVER['PHP_AUTH_USER']).", there was an error uploading your file.";
}
}
?>
我尝试过应用相同的模式,但由于某些原因,它不起作用。同样感谢Tim,这适用于整个代码
if (file_exists($target_file)) {
echo " Sorry ".ucfirst($_SERVER['PHP_AUTH_USER']).", the file already exists. Please try renaming or adding a version number.";
$uploadOk = 0;
}
// Check if $uploadOk is set to 0 by an error
if ($uploadOk == 0) {
echo " Sorry ".ucfirst($_SERVER['PHP_AUTH_USER']).", your file was not uploaded.";
// if everything is ok, try to upload file
} else {
if (move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], $target_file)) {
echo "Thank You, ".ucfirst($_SERVER['PHP_AUTH_USER']).". The file ". basename( $_FILES["fileToUpload"]["name"]). " has been uploaded.";
} else {
echo " Sorry ".ucfirst($_SERVER['PHP_AUTH_USER']).", there was an error uploading your file.";
}
}
?>
您只需将文本和服务器输入的部分分开,它就可以工作了
echo“谢谢,”.ucfirst($\u SERVER['PHP\u AUTH\u USER'])。“.thefile”。basename($_文件[“fileToUpload”][“name”])。“已上载。”代码>英雄,@tim。将其添加为答案,以便我可以为您接受:)@tim我已编辑该问题,将您的答案包含在代码中相关的所有地方,并尝试实现它。不幸的是,仍然没有运气。如果你能帮我看一下,我会很感激的?你确定$\u SERVER['PHP\u AUTH\u USER']
是你想要的变量吗?是的,我确定它就是我想要的变量。我已将您的代码应用于每个实例,但它仅在最初发布的感谢消息中大写用户名。