Php 移动上传功能不工作

Php 移动上传功能不工作,php,Php,我试图在我的服务器上传图像,但图像没有上传 我在临时文件中遇到了一个问题 C:\Windows\Temp\phpE69F.tmp 如何在我的服务器上上传文件 我的代码是: if(isset($_POST['submit'])){ echo "Temp file: " . $_FILES["file"]["tmp_name"] . "<br />"; $sourcePath = $_FILES['file']['Tmp_name']; if ($sourceP

我试图在我的服务器上传图像,但图像没有上传

我在临时文件中遇到了一个问题

C:\Windows\Temp\phpE69F.tmp 如何在我的服务器上上传文件

我的代码是:

if(isset($_POST['submit'])){

    echo "Temp file: " . $_FILES["file"]["tmp_name"] . "<br />";
    $sourcePath = $_FILES['file']['Tmp_name'];
    if ($sourcePath) {
        $targetPath = "images/" . $_FILES['file']['name'];
       if(move_uploaded_file($sourcePath, $targetPath)) {

           echo 'success';
       } else {

           echo 'fail';
       }

    } else {

        echo 'temp path not define';
    }

}
if(isset($\u POST['submit'])){
回显“临时文件:”.$\u文件[“文件”][“tmp\u名称”]。“
”; $sourcePath=$\u文件['file']['Tmp\u名称']; 如果($sourcePath){ $targetPath=“images/”$\u文件['file']['name']; if(移动上传的文件($sourcePath,$targetPath)){ 呼应"成功",; }否则{ 回声“失败”; } }否则{ 回显“临时路径未定义”; } }
我看到您使用的是W3Schools的示例,在您的帖子中,您只复制了检查部分,但在页面末尾,您将看到完整的源代码


看看

我看到您使用的是W3Schools的示例,在您的帖子中,您只复制了检查部分,但在页面末尾,您将看到完整的源代码

echo "Temp file: " . $_FILES["file"]["tmp_name"] . "<br />";
$sourcePath = $_FILES['file']['Tmp_name']; // <= WRONG index with uppercase should be ['tmp_name']

看看

echo“临时文件:”$_文件[“文件”][“tmp_名称”]。“
”;
echo "Temp file: " . $_FILES["file"]["tmp_name"] . "<br />";
$sourcePath = $_FILES['file']['Tmp_name']; // <= WRONG index with uppercase should be ['tmp_name']
$sourcePath=$\u FILES['file']['Tmp\u name'];//<代码>回显“临时文件:”$_文件[“文件”][“tmp_名称”]。“
”;

$sourcePath=$\u FILES['file']['Tmp\u name'];//如标题中所述,代码中缺少该函数。不,我尝试上载。等待检查此代码:if(isset($\u POST['submit']){echo“Temp file:”.$\u FILES[“file”][“tmp\u name”]。“
”;$sourcePath=$\u FILES['file']['tmp\u name'];if($sourcePath){$targetPath=“images/”$\u FILES['file']['name'];if(move\u上传的\u file($sourcePath,$targetPath)){echo'success';}其他{echo'fail';}其他{echo'temp path未定义';}然后,请提供您尝试上载图像的代码,而不仅仅是检查代码。@ashishrana如果您是指w3schools,请使用最后一部分提供的完整代码。您提供的部分不是标题中描述的,代码中缺少该函数。否,我尝试上载。请等待检查此代码:if(isset($\u POST['submit']){echo“Temp file:”.$\u FILES[“file”][“tmp\u name”]。“
”;$sourcePath=$\u FILES[“file”][“tmp\u name”];if($sourcePath){$targetPath=“images/”$\u FILES[“file”][“name”];if(move\u上传的文件($sourcePath,$targetPath)){echo'success';}其他{echo'fail';}其他{echo'temp path not define';}然后,请提供您尝试上载图像的代码,而不仅仅是检查。@ashishrana如果您是指w3schools,请使用上一部分给出的完整代码。您给出的部分没有更改,但没有效果。实际上,我的临时路径是C:\Windows\temp\phpE69F.tmphow我可以更改临时路径,但没有效果CTactualu我的临时路径是C:\Windows\temp\phpE69F.tmp我可以更改临时路径我的临时路径是C:\Windows\temp\phpE69F.tmp我如何更改这个临时路径,你有没有想法用PHP用代码
ini\u集('upload\tmp\u dir','your/path/here/')覆盖它
或更改php.ini文件中的目录。先生,从我们获取php.ini文件的地方我已经转到了服务器,当我打开服务器时,在我的服务器中找不到php.ini文件。这是一个共享主机,我想他们不允许用户覆盖php.ini文件。我的临时路径是C:\Windows\temp\phpE69F.tmp如何更改这个临时路径,di你有什么想法吗?用PHP覆盖代码
ini\u集('upload\u tmp\u dir','your/path/here/'))
或更改php.ini文件中的目录。先生,从那里我们可以得到php.ini文件。我打开服务器时,在我的服务器中找不到php.ini文件。这是一个共享主机,我想他们不允许用户覆盖php.ini文件。