-1
我有一個小問題,我想不出我需要上傳一個圖片到一個名爲上傳的文件夾我成功上傳了圖片的名稱到數據庫表,但由於某種原因圖片沒有上傳到這裏的文件夾是我的代碼圖片無法上傳到文件夾
<?PHP
session_start();
$_SESSION['url'] = $_SERVER['REQUEST_URI'];
if (!(isset($_SESSION['email']) && $_SESSION['email'] != '')) {
header ("Location: log-in/login");
}
?>
<?php
include('configur.php');
if(isset($_SESSION['email'])){
echo "Welcome '{$_SESSION['email']}'";
}
?> <?php
echo"<a href = log-in/logout> Log out </a>";
?><br> <br>
<?php
require_once("configur.php"); \t
$query='UPDATE profile_table SET images="'.$_FILES['file']['name'].'"
WHERE email= "'.$_SESSION['email'].'"';
if ($mysqli->query($query) === TRUE) {
echo "Record updated successfully";
} else {
echo "Error updating record: " . $conn->error;
}
$mysqli->close();
?>
<?php
include('configur.php');
if($_POST)
{
// $_FILES["file"]["error"] is HTTP File Upload variables $_FILES["file"] "file" is the name of input field you have in form tag.
if ($_FILES["file"]["error"] > 0)
{
// if there is error in file uploading
echo "Return Code: " . $_FILES["file"]["error"] . "<br />";
}
else
{
// check if file already exit in "images" folder.
if (file_exists("upload" . $_FILES["file"]["name"]))
{
}
else
{ //move_uploaded_file function will upload your image.
if(move_uploaded_file($_FILES["file"]["tmp_name"],"upload" . $_FILES["file"]["name"]))
{
// If file has uploaded successfully, store its name in data base
$query_image = "insert into profile_table";
if(mysqli_query($link, $query_image))
{
echo "Stored in: " . "upload" . $_FILES["file"]["name"];
}
else
{
echo'';
}
}
}
}
}
?>