如果文件大小大于1MB,我正在使用代码来调整图像大小,我在模型函数中使用了此功能,但是返回的是false。这里有什么不对。
<doctype! html>
<html>
<head>
<link href="https://cdn.rawgit.com/michalsnik/aos/2.1.1/dist/aos.css" rel="stylesheet">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Oops.. Dead End</title>
<script src="https://cdn.rawgit.com/michalsnik/aos/2.1.1/dist/aos.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-136743580-1"></script>
<div id="header">adamferreira</div>
<div id="navigation">
<ul>
<a class="nav" href="index.html"> Return Home</a>
</ul>
</div>
<div class="headerBackground"></div>
<body>
<div class="container" data-aos="ease-in-out-back" data-aos="zoom out">
<h1>Looks like this page doesn't exist</h1>
<h1 class="feedback">Please double-check you are entering the correct information in your address bar.<br> This page may also have been moved, deleted or a feature may not be available to you.</h1>
</head>
</body>
</html>
答案 0 :(得分:0)
您不应在if中加载image_lib。尝试使用下面的代码
$this->load->library('image_lib');
if($_FILES[$name]['size']/(1024)>1024){
$upload_data = $this->upload->data();
$config2['image_library'] = 'ImageMagick';
$config2['source_image'] = $upload_data["file_path"];
$config2['create_thumb'] = TRUE;
$config2['maintain_ratio'] = TRUE;
$config2['quality'] = '60%';
$config2['width'] = 200;
$config2['height'] = 200;
//$config2['new_image'] = $upload_data["file_name"];
$this->image_lib->clear();
$this->image_lib->initialize($config2);
var_dump($this->image_lib->resize());
}