无法通过PHP将图像文件保存到服务器

无法通过PHP将图像文件保存到服务器,php,html,Php,Html,在那里。我对PHP不是很有经验,但我负责修改一个使用PHP的网站。部分功能是上传图像并将其显示在页面上。我已经获得了写入数据库的图像名称,以及在数据库字段不为空时显示的图像HTML。但是,我不知道如何将图像保存到服务器。任何帮助都将不胜感激 HTML: 确保您$path=“../\u citylogo/logo/”$filename是可写的当你写一个关于错误的问题时,一定要包括错误的详细信息。在打开PHP标记后立即在文件顶部添加错误报告,例如确保$path=“../\u citylogo/log

在那里。我对PHP不是很有经验,但我负责修改一个使用PHP的网站。部分功能是上传图像并将其显示在页面上。我已经获得了写入数据库的图像名称,以及在数据库字段不为空时显示的图像HTML。但是,我不知道如何将图像保存到服务器。任何帮助都将不胜感激

HTML:


确保您
$path=“../\u citylogo/logo/”$filename是可写的

当你写一个关于错误的问题时,一定要包括错误的详细信息。在打开PHP标记后立即在文件顶部添加错误报告,例如
确保
$path=“../\u citylogo/logo/”$filename是writable@NishanthMatha谢谢,谢谢,谢谢,谢谢。这就是问题所在!该死的,别担心。很乐意帮忙!
<form action="<?php echo $editFormAction; ?>" method="post" enctype="multipart/form-data" name="form1" id="form1">
    <label for="logo">Primary Logo Upload:</label> <input type="file" id="logo" name="logo" class="fullWidth" ><br>
    <input type="submit" value="Save Changes">
    <input type="hidden" name="logo" value="<?php echo $row_RecordsetCity['logo']; ?>" />
</form>
$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
    $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}
if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form1")) {

    $location = $_FILES['logo'];
    $image = rand(1,2);
    $image = $image * time();
    $image = $image."-lp".".jpg";
    $filename = $image;
    $path="./_citylogo/logo/".$filename;
    $tempname=$location['tmp_name'];
    copy($tempname,$path);
    if ($location['name'] == "") {
        $_POST['logo'] = $_POST['logo'];
    } else {
       $_POST['logo'] = $image;
    }
}
$tempname= $location['tmp_name'];
$name = $location['tmp_name'];
$folder_directory = 'foldername/';
$check_folder_exists = is_dir($folder_directory);

if(!$check_folder_exists){
    mkdir($folder_directory , 0755, true);
//create folder if it doesn't exists.
//0755 - the image file can be access for the owner, while other can read and execute it.

}

$file_directory = $folder_directory.$name;
$move_temp_file = move_uploaded_file($tempname, $file_directory);

//note: This next part is optional.
if($move_temp_file){
    chmod($file_directory, 644);
//chmod() change the image file so it can't to executable by other in your server incase some hacker, upload a bad image.
}