Codeigniter에서 jQuery Coppie[잘라내기 및 저장] 이미지 사용하기 - 한 걸음 한 걸음
1720 단어 htmlcsslaravelcodeigniter
이 자습서에서는 PHP의 자르기 이미지를 학습합니다.이 자습서는 Codeigniter 4 프로젝트에서 jQuery와 aax를 사용하여 이미지를 업로드합니다.이미지는 Ajax를 사용하여 데이터베이스에 저장하기 전에 이미지 크기를 자르고 조정하는 미리 보기를 표시합니다.CodeIgniter 프로젝트의 웹 페이지를 새로 고치거나 다시 로드할 필요가 없습니다.
<?php namespace App\Controllers;
use CodeIgniter\Controller;
class CropImageUpload extends Controller
{
public function index()
{
return view('crop-image-upload-form');
}
public function store()
{
helper(['form', 'url']);
$db = \Config\Database::connect();
$builder = $db->table('crop_images');
$data = $_POST["image"];
$image_array_1 = explode(";", $data);
$image_array_2 = explode(",", $image_array_1[1]);
$data = base64_decode($image_array_2[1]);
$imageName = time() . '.png';
file_put_contents($imageName, $data);
$image_file = addslashes(file_get_contents($imageName));
$save = $builder->insert(['title' => $image_file]);
$response = [
'success' => true,
'data' => $save,
'msg' => "Crop Image has been uploaded successfully in codeigniter"
];
return $this->response->setJSON($response);
}
}
[Crop and Save] Image using jQuery Coppie in Codeigniter
Reference
이 문제에 관하여(Codeigniter에서 jQuery Coppie[잘라내기 및 저장] 이미지 사용하기 - 한 걸음 한 걸음), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://dev.to/robertlook/crop-and-save-image-using-jquery-coppie-in-codeigniter-step-by-step-316텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념 (Collection and Share based on the CC Protocol.)