为了账号安全,请及时绑定邮箱和手机立即绑定

感谢登录用户上传文件

感谢登录用户上传文件

PHP
泛舟湖上清波郎朗 2021-08-28 17:18:51
我需要大写感谢用户的姓名。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.";但这只是输出它。任何使用户名以这种格式大写的帮助将不胜感激。EDIT在 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 errorif ($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.";    }}?>我试过应用相同的模式,但由于某种原因它不起作用。
查看完整描述

1 回答

?
森林海

TA贡献2011条经验 获得超2个赞

还要感谢 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.";

    }

}

?>

您只需要拆分文本部分和服务器输入即可使其工作。


查看完整回答
反对 回复 2021-08-28
  • 1 回答
  • 0 关注
  • 108 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信