【发布时间】:2016-10-04 06:42:34
【问题描述】:
我正在 CodeIgniter 中上传图片文件。我想在我的代码中追踪图像并用它更新我的数据库路径。我想在下面的代码中打印$image_path 变量,它位于我的控制器中。
如何打印$image_path 变量以在控制器内显示或检查其值,或者将其回显出来?
这里是:
<?php
public function upload_file()
{
$status = "";
$msg = "";
$file_element_name = 'userfile';
if ($status != "error") {
$config['upload_path'] = './assets/upimages/';
$config['allowed_types'] = 'gif|jpg|png';
$config['max_size'] = 1024 * 8;
$config['encrypt_name'] = FALSE;
$this->load->library('upload', $config);
if (!$this->upload->do_upload($file_element_name))
{
$status = 'error';
$msg = $this->upload->display_errors('', '');
}
else
{
$data = $this->upload->data();
$image_path = $data['full_path'];
if(file_exists($image_path))
{
$status = "success";
$msg = "File successfully uploaded";
}
else
{
$status = "error";
$msg = "Something went wrong when saving the file, please try again.";
}
}
@unlink($_FILES[$file_element_name]);
}
echo json_encode(array('status' => $status, 'msg' => $msg));
}
?>
【问题讨论】:
-
感谢编辑先生
标签: php codeigniter controller