0

我有一个有效的上传表格,然后最近为我一直在制定一个预先存在的计划的网站购买了一个专用的托管计划(GoDaddy - 是的,我知道的邪恶)。但是,尽管文件结构与完全写入权限完全相同,但上传不再有效,但数据库已更新,尽管数据库仅在存在图像时才更新。我不明白为什么不再上传文件:

if ($state == "post") {
    $title = $_POST['title'];
$body = $_POST['body'];
if(! empty($_FILES['file']['name'][file])) {
    $allowed_extensions = array("jpeg", "jpg", "png");
    $upload_extension = end(explode(".", $_FILES['file']['name'][file]));
    if (in_array($upload_extension, $allowed_extensions)) {
    $loop = true;
    $im = null;
    while ($loop) {
        $rand_count = 0;
        while ($rand_count != 10) {
            $rand = rand(1,9);
        $im = $im . $rand;
        $rand_count++;
        }
        $image = $im.".".$upload_extension;
        if (!file_exists("images/posts/" . $image)) {
            list($width, $height) = getimagesize($_FILES['file']['tmp_name'][file]);
        if ($height > $width)
                        $width_n = 160; $height_n = $height/$width*$width_n;
        else
            $height_n = 160; $width_n = $width/$height*$height_n;

            $tmp_image = imagecreatetruecolor($width_n, $height_n);
        if (($upload_extension == "jpeg") || ($upload_extension == "jpg"))
                        $src = imagecreatefromjpeg($_FILES['file']['tmp_name'][file]);
        elseif ($upload_extension == "png")
            $src = imagecreatefrompng($_FILES['file']['tmp_name'][file]);
        //tmp_upload 
        imagecopyresampled($tmp_image, $src, 0, 0, 0, 0, $width_n, $height_n, $width, $height);
        $path = "images/posts/".$image;
        imagejpeg($tmp_image, $path, 100);
                    $stmt = "INSERT INTO posts (post_title, post_body, post_image) VALUES ('$title', '$body', '$image')";
        if (!mysqli_query($con, $stmt))
                        die('Error: ' . mysqli_error($con));
            $loop = false;
        header('Location: index.php');
        }
    }
    }
}
}

images/posts存在于新服务器上。

4

1 回答 1

0

$_FILES以完全错误的方式使用。在您使用它的每个实例中,您都需要删除尾随[file]

IE

$_FILES['file']['tmp_name'][file]

变成

$_FILES['file']['tmp_name']
于 2013-09-20T15:36:53.737 回答