我在更新用户个人资料图片时遇到问题。将数据粘贴到表单中并单击提交按钮后,显示“已更改”。除了个人资料图片外,一切都真的发生了变化。问题是图像没有存储在文件夹中。同时我不知道为什么。有人可以帮帮我吗?
<?php
session_start();
include_once 'dbconnect.php';
if (isset($_POST['ulozitzmeny']) && ($_SESSION['user']) && strlen($_SESSION['user']) > 0) {
$first_name = mysql_real_escape_string($_POST['jmeno']);
$last_name = mysql_real_escape_string($_POST['prijmeni']);
$email = mysql_real_escape_string($_POST['email']);
$password = hash('sha512', mysql_real_escape_string($_POST['heslo']));
$file = rand(1000, 100000) . "-" . $_FILES['file']['name'];
$file_loc = $_FILES['file']['tmp_name'];
$file_size = $_FILES['file']['size'];
$file_type = $_FILES['file']['type'];
$folder = "images/";
$new_size = $file_size / 1024;
$new_file_name = strtolower($file);
$final_file = str_replace(' ', '-', $new_file_name);
move_uploaded_file($file_loc,$folder.$final_file);
$res = mysql_query("SELECT password FROM users WHERE username='$_SESSION[user]'");
$row = mysql_fetch_array($res);
$sql = "SELECT file FROM users WHERE username='$_SESSION[user]'";
$result_set = mysql_query($sql);
$row2=mysql_fetch_array($result_set);
if ($password != $row[0]) {
echo" <div style='position:absolute;left:29.5%;top:10%;width:41%;' class='alert alert-danger fade in'>
<a href='#' class='close' data-dismiss='alert' aria-label='close'>×</a>
<strong>Chyba!</strong> Nespávné heslo!
</div>";
} else {
if (mysql_query("UPDATE users SET first_name='$first_name', last_name='$last_name', email='$email', file='$final_file', type='$file_type', size='$new_size' WHERE username = '$_SESSION[user]'")or die(mysql_query)) {
echo" <div style='position:absolute;left:29.5%;top:10%;width:41%;' class='alert alert-success'>
<a href='#' class='close' data-dismiss='alert' aria-label='close'>×</a>
<strong>Úspěch!</strong> Změny proběhly úspěšně!
</div>";
}
}
}
?>