-2
저는 엑셀 시트를 사용하고 응용 프로그램 작성을 위해 CakePHP 3.2를 사용하는 대량 업로드 프로젝트를 진행하고 있습니다.PHP의 로컬 경로에서 이미지 가져 오기
나는 업로드 할 이미지를 제공하는 Excel 시트가 있습니다.
사용자가 대량 업로드하기 전에 미리 정의 된 디렉토리 중 하나
- 업로드 이미지로 이동 한 경로에서 자동으로 선택됩니다 셀 및 이미지에 이미지의 이름을 제공하는 3 개 선택이있다.
- 는 로컬 컴퓨터에있는 경우
- 이미지의 경로를 부여 이미지 (http://website/path/image.jpg)의 URL을 지정합니다. . 예,C : \ 사용자 \ 사진 \ image.jpg를 윈도우 및 /home/user/picture/image.jpg이
이이 리눅스 경우 경우 이미지를 저장하기 위해 내가하고있는 일
$p_image = $objWorksheet->getCellByColumnAndRow(30, $row)->getValue();
if (filter_var($p_image, FILTER_VALIDATE_URL)) {
// get image from url
$full_image_path = $p_image;
} else {
// get image from folder
$path = Configure::read('media.bulkUpload.pre.product');
// full path of the image from root directory
$full_image_path = $path . DS . $p_image;
}
$upload_path = Configure::read('media.upload') . DS . 'files' . DS;
// new name of image
$img_new_name = uniqid('img_').round(microtime(true) * 1000).rand(1,100000);
if ($full_image_path) {
// generate uuid directory name
$dir = Text::uuid();
// create new directory
mkdir($upload_path.$dir, 0777, true);
// save file
try {
$img = new \abeautifulsite\SimpleImage($full_image_path);
// save image of original size
$img->best_fit(850,1036)->save($upload_path.$dir.'/'.$img_new_name.'.jpg');
} catch(Exception $e) {
echo 'Error: '.$e->getMessage();
}
}
URL을 사용한 이미지 업로드와 프리 ftp 업로드가 정상적으로 작동합니다. 그러나 어떻게하면 로컬 시스템의 경로에서 이미지를 가져 와서 저장할 수 있습니까?