我无法在php中获取会话变量我已经在主html页面中启动了会话。只有当部分工作时,其他部分的其余部分才会给出任何结果。 在标题部分重新加载页面时,它给我一个错误
注意:尝试获取非对象的属性 C:\瓦帕\ WWW \ PHPMailer的\额外\ JS \ post_action.php
post_action.php
<form method='post' id='submit_form' action="process/upload_new.php?id=<?php echo $id; ?>" enctype="multipart/form-data">
<tr>
<td class="col-md-4">Upload Image</td>
<td class="col-md-8"><input name='post_image' value='<?php echo $rows["post_image"]; ?>' type="file" placeholder="Site Titlebar" class="form-control" />
<br>
<input name='submit' id='submit' type="submit" value='Upload Image' class="btn btn-success" />
</td>
</tr>
<tr>
<td>
<p> Image Preview </p>
</td>
<td>
<img src='<?php echo $rows["post_image"]; ?>' width='100px' height='100px' />
</td>
</tr>
</form>
过程/ upload_new.php
<?php
if($_FILES['post_image']['name'] != ''){
$uploaded_file = $_FILES['post_image']['name'];
$exp = explode(".",$uploaded_file);
$extension = end($exp);
$allowed_types = array('jpg',"jpeg","png","gif");
if(in_array($extension,$allowed_types))
{
if(is_uploaded_file($_FILES['post_image']['tmp_name'])){
$new_name = rand().".".$extension;
$path = "../images/".$new_name;
if(move_uploaded_file($_FILES['post_image']['tmp_name'],$path))
{
$_SESSION['upload_success'] = "File Uploaded succesfully";
$db_path = "images/".$new_name;
$values = ['post_image' => $db_path]; #calling update method to update image;
$id = $_GET['id'];
include_once "action_page.php";
$tablename = 'posts';
$abc = new Demo();
$res = $abc->edit($tablename,$values,$id);
unset($abc);
$_SESSION['upload_success'] = "File Uploaded succesfully";
//header("location:../post_action.php?id=$id");
}
else
{
$_SESSION['upload_error'] = "Something went wrong, file cannot be uploaded";
//header("location:../post_action.php?id=$id");
}
}
else
{
$_SESSION['upload_error'] = "Cannot upload file";
//header("location:../post_action.php?id=$id");
}
}
else{
$_SESSION['upload_warning'] = "Please upload appropriate file type";
//header("location:../post_action.php?id=$id");
}
}
else
{
$_SESSION['upload_warning'] = "Please upload file";
header("location:../post_action.php?id=$id");
}