我正在尝试调整大小,然后在CodeIgniter中上传图像。它会上传图片,但不会调整图片大小。
<style>
nav a {
text-decoration: none;
color: black;
overflow: hidden;
padding-left: 20px;
}
nav {
background-color: #ffffff;
height: 75px;
}
ul{
margin-top:0;
height:50px;
}
.right-menu {
position:absolute;
right:0;
top:0;
width:400px;
}
.left-menu {
position:absolute;
left:0;
top:0;
width:300px;
}
nav li {
list-style: none;
text-decoration: none;
padding: 2%;
align-items: center;
overflow: hidden;
display: inline-block;
height:100%;
}
nav img {
margin-top: .8%;
margin-left: 2%;
height: 50px;
width: auto;
position: relative;
}
</style>
</head>
<body>
<nav>
<ul class="left-menu">
<li><img src="Lorem_Ipsum-logo-1662AFAE6D-seeklogo.com.gif" href="index.html"> </li>
<li><a href="index.html" class="homenav">Home</a></li>
</ul>
<ul class="right-menu">
<li><a href="#contact">Contact Us</a></li>
<li><a href="about.html">About Us</a></li>
<li><a href="photos.html">Products</a></li>
</ul>
</nav>
</body>
答案 0 :(得分:0)
首先,您尝试在实际上传文件之前调整的大小。其次,您需要为图像处理类提供上载图像的完整路径(再次,在您上传图像后)。第三,最好为不同的配置使用不同的变量名称:
$config['upload_path'] = './assets/uploads';
$config['allowed_types'] = 'gif|jpg|png|jpeg';
$this->load->library('upload', $config);
if ($this->upload->do_upload('resim')) {
$file_data = $this->upload->data();
$resize['image_library'] = 'gd2';
$resize['create_thumb'] = TRUE;
$resize['maintain_ratio'] = TRUE;
$resize['quality'] = '60%';
$resize['width'] = 200;
$resize['height'] = 200;
$resize['source_image'] = $file_data['full_path'];
$this->load->library('image_lib', $resize);
if (!$this->image_lib->resize()) {
echo $this->image_lib->display_errors();
}
} else {
echo $this->upload->display_errors('<p>', '</p>');
}