我想用兩種功能創建兩個具有不同大小的縮略圖。上傳圖片() 使uploadIhumb($ name){它在第一個函數內調用}創建小縮略圖。 第一個功能創建縮略圖但第二個不起作用。 請解決問題並突出顯示問題出在哪裏?CodeIgniter圖像縮略圖問題
enter code here:
function uploadImage()
{
$imageName2=$_FILES['file']['tmp_name'];
$config['image_library'] = 'gd2';
//$config['source_image'] = $imageName2;// this is temporary folder where image place on uploading time
$config['create_thumb'] = TRUE;
$config['maintain_ratio'] = false;
$config['width'] = 696;
$config['height'] = 241;
$config['new_image'] = 'images/uploads';
$this->load->library('image_lib', $config);
$this->image_lib->resize();
$file_name= basename($imageName2, ".tmp");
$filename=$file_name.'_thumb.tmp';
////////////////////Rename code///////////////////////////
$name= $this->rand_string(6);
$dir=$_SERVER['DOCUMENT_ROOT'].'/images/uploads/';
rename($dir . $filename, $dir . $name);
echo $name;
$this->uploadIhumb($name); //FUNCTION CALL
}
function uploadIhumb($name)
{
$config['image_library'] = 'gd2';
$config['source_image'] = $_SERVER['DOCUMENT_ROOT'].'/images/uploads/'.$name;
$config['create_thumb'] = TRUE;
$config['width'] = 80;
$config['height'] = 80;
$config['new_image'] = $_SERVER['DOCUMENT_ROOT'].'images/uploads/thumbs/';
$this->load->library('image_lib', $config);
$this->image_lib->resize();
}
尊敬的先生;發生以下錯誤: - 您的服務器不支持處理此類圖像所需的GD功能。 –
你有寫權限的目錄嗎?你也可以嘗試改變'$ config ['image_library'] ='gd2'; 'to'$ config ['image_library'] ='GD'; ' – smilledge
另外,請確保「source_image」和「new_image」的位置正確...並且您想要上傳什麼樣的格式圖像?它與JPEG圖像一起工作嗎? – smilledge