我的观点看起来:
<form action="<?php echo site_url('Admin/addBrandsProcess'); ?>" class="dropzone" >
</form>
我的控制器看起来:
public function addBrandsProcess()
{
$query = $this->db->query('SELECT width, height FROM brandimage');
foreach ($query->result() as $row)
{
$width= $row->width;
$height= $row->height;
}
if (!empty($_FILES))
{
$tempFile = $_FILES['file']['tmp_name'];
$fileName = $_FILES['file']['name'];
$targetPath = getcwd() . './assets/images/brand/';
$targetFile = $targetPath . $fileName ;
move_uploaded_file($tempFile, $targetFile);
$config['image_library'] = 'gd2';
$config['source_image'] = $targetPath . $fileName ;
$config['overwrite'] = TRUE;
$config['create_thumb'] = FALSE;
$config['thumb_marker'] = '_thumb';
$config['maintain_ratio'] = FALSE;
$config['width'] = $width;
$config['height'] = $height;
$config['quality'] = '100%';
$this->load->library('image_lib', $config);
$this->image_lib->resize();
$this->db->insert('brands',array('image' => $fileName));
}
}
此代码在本地服务器中运行良好,但在实时服务器中运行良好。这里我的问题是图像没有上传到目标文件夹。此处,图片名称将保存在品牌表格中。但是图像未上传到目标路径 $ targetPath = getcwd()。 &#39; ./资产/图像/品牌/&#39 ;;
我该如何解决这个问题。所有变化必须做什么。