Tôi đã thực hiện tải lên hình ảnh, thay đổi kích cỡ nhiều lần trong CI. Mã tương tự đang hoạt động trên một trang nhưng không hoạt động ở trang khác. khi tôi hiển thị lỗi, thông báo "Máy chủ của bạn không hỗ trợ chức năng GD cần thiết để xử lý loại hình ảnh này". Mã để tải lên hình ảnh là ... \Máy chủ của bạn không hỗ trợ chức năng GD cần thiết để xử lý loại hình ảnh này.
function do_upload() {
$original_path = './uploads/activity_images/original';
$resized_path = './uploads/activity_images/resized';
$thumbs_path = './uploads/activity_images/thumb';
$this->load->library('image_lib');
$config = array(
'allowed_types' => 'jpg|jpeg|gif|png', //only accept these file types
'max_size' => 2048, //2MB max
'upload_path' => $original_path //upload directory
);
$this->load->library('upload', $config);
$this->upload->do_upload();
$image_data = $this->upload->data(); //upload the image
$image1 = $image_data['file_name'];
//your desired config for the resize() function
$config = array(
'source_image' => $image_data['full_path'], //path to the uploaded image
'new_image' => $resized_path,
'maintain_ratio' => true,
'width' => 128,
'height' => 128
);
$this->image_lib->initialize($config);
$this->image_lib->resize();
// for the Thumbnail image
$config = array(
'source_image' => $image_data['full_path'],
'new_image' => $thumbs_path,
'maintain_ratio' => true,
'width' => 36,
'height' => 36
);
//here is the second thumbnail, notice the call for the initialize() function again
$this->image_lib->initialize($config);
$this->image_lib->resize();
//$this->image_lib->clear();
echo $this->image_lib->display_errors();
var_dump(gd_info());
die();
return $image1;
}
Điều gì đang diễn ra mà tôi không thể hiểu được .. ??
gì không 'var_dump (gd_info());' cung cấp cho bạn? –
mảng 'Phiên bản GD' => chuỗi 'đi kèm (tương thích 2.0.34)' (length = 27) 'Hỗ trợ FreeType' => boolean true 'FreeType Linkage' => string 'with freetype' (length = 13) 'T1Lib Hỗ trợ' => boolean false 'Hỗ trợ GIF đọc' => boolean true 'GIF Tạo Hỗ trợ' => boolean true 'JPEG Hỗ trợ' => boolean true 'PNG Hỗ trợ' => boolean true 'WBMP Hỗ trợ '=> boolean true ' Hỗ trợ XPM '=> boolean false ' Hỗ trợ XBM '=> boolean true ' Hỗ trợ Phông chữ Nhật Bản được JIS lập bản đồ '=> boolean false – Drudge
Bạn cũng có '$ config [' image_library '] = 'gd2'; '? –