Php 文件未上载到带有move_uploaded_file()的文件夹中。怎么了?

Php 文件未上载到带有move_uploaded_file()的文件夹中。怎么了?,php,file-upload,Php,File Upload,我很恼火,因为当我添加一篇文章时,这个代码是有效的。但是,当我编辑帖子时,此代码不希望将新更新的图像上载到文件夹中。是的,但它是一个“坏”文件,没有正确上传。为什么我会有这些问题 <?php if (isset($_POST['postupdate'])) { $editPostTitle = trim($_POST['editposttitle']); $editPostAuthor = trim($_POST['editpostauthor']); $edit

我很恼火,因为当我添加一篇文章时,这个代码是有效的。但是,当我编辑帖子时,此代码不希望将新更新的图像上载到文件夹中。是的,但它是一个“坏”文件,没有正确上传。为什么我会有这些问题

<?php
if (isset($_POST['postupdate'])) {

    $editPostTitle = trim($_POST['editposttitle']);
    $editPostAuthor = trim($_POST['editpostauthor']);
    $editPostStatus = trim($_POST['editpoststatus']);
    $editPostTags = trim($_POST['editposttags']);
    $post_image = $_FILES['editimage']['name'];
    $post_image_temp = $_FILES['editimage']['tmp_name'];
    $editPostContent = trim($_POST['editpostcontent']);

    move_uploaded_file($post_image_temp, "./images/".$post_image);
    print_r(error_get_last());

    $updateposts = $conn->prepare("
    UPDATE posts 
    SET post_title = ?, post_author = ?, post_tags = ?, post_image = ?, post_content = ?
    WHERE post_id = ?
    ");
    $updateposts->bind_param("sssssi", $editPostTitle, $editPostAuthor, $editPostTags, $editPostImage, $editPostContent, $editId);
    $updateposts->execute();
    $updateposts->close();



}

好了,各位,奇怪的是,这是因为我添加了一个引导类属性

问题是:

<input type="file" name="editimage" id="editimage" class="form-control"/>

我认为你必须为下面这样的图像使用完美的路径
move_-upload_文件($post_-image_-temp,Yii::getAlias('@webroot')。“/images/”$post_-image)路径是您的项目/web/images/check输入文件具有文件路径($\u FILES['editimage'])我看到了一些错误,不知道是否是原因,但请更改它们,在sql查询bindparam中,您传递的$editPostImage不是脚本中的变量,请传递$post\u图像,因为它保存了name@Exprator我明白了。变量名最初是变量名。我只是把它改了一下,看看这是否是文件没有上传的原因,然后忘了更正它。查看您的日志文件/var/log/httpd/error\u log
class="form-control"