Мне понадобились все доступные параметры, с удовольствием поделюсь.
imageUploadURL: 'image_upload.php',
imageUploadParams: {
path: '/images/'
},
imageManagerLoadURL: 'image_load.php',
imageManagerLoadParams: {
path: '/images/'
},
imageManagerLoadMethod: 'POST',
imageManagerDeleteURL: 'image_delete.php',
image_upload.php:// Allowed extentions.
$allowedExts = array("gif", "jpeg", "jpg", "png", "blob");
// Get filename.
$temp = explode(".", $_FILES["file"]["name"]);
// Get extension.
$extension = strtolower(end($temp));
// An image check is being done in the editor but it is best to
// check that again on the server side.
// Do not use $_FILES["file"]["type"] as it can be easily forged.
$finfo = finfo_open(FILEINFO_MIME_TYPE);
$mime = finfo_file($finfo, $_FILES["file"]["tmp_name"]);
if ((($mime == "image/gif")
|| ($mime == "image/jpeg")
|| ($mime == "image/pjpeg")
|| ($mime == "image/x-png")
|| ($mime == "image/png"))
&& in_array($extension, $allowedExts)) {
$path = base_path() . '/public/images/' . $_POST['path'];
if ( !is_dir($path) ) \File::makeDirectory($path, 0775, true);
// image
$img = $_FILES["file"];
$name = strtolower($img['name']);
$src = $path . $name;
$imgM = Image::make($img['tmp_name']);
if ( isset($_POST['save']) ){
$imgM = $imgM->fit(200, 200);
$user->photo = $_POST['path'].$name;
$user->save();
}
$imgM->save($src);
// Generate response.
$response = new \StdClass;
$response->link = $_POST['path'] . $name;
echo stripslashes(json_encode($response));
}
Данный файл выполняет функцию вывода изображений в список окна выбора ранее загруженных.image_load.php:// Array of image objects to return.
$response = array();
// Image types.
$image_types = array(
"image/gif",
"image/jpeg",
"image/pjpeg",
"image/jpeg",
"image/pjpeg",
"image/png",
"image/x-png"
);
// Filenames in the uploads folder.
$path = $_POST['path'];
$fnames = scandir($path);
// Check if folder exists.
if ($fnames) {
// Go through all the filenames in the folder.
foreach ($fnames as $name) {
// Filename must not be a folder.
if (!is_dir($name)) {
// Check if file is an image.
if (in_array(mime_content_type(getcwd() . '/' . $path . $name), $image_types)) {
// Build the image.
$img = new \StdClass;
$img->url = $_POST['path'] . $name;
$img->thumb = $_POST['path'] . $name;
$img->name = $name;
// Add to the array of image.
array_push($response, $img);
}
}
}
}
// Folder does not exist, respond with a JSON to throw error.
else {
$response = new \StdClass;
$response->error = "Images folder does not exist!";
}
$response = json_encode($response);
// Send response.
echo stripslashes($response);
image_delete.php:// Get src.
$src = getcwd() . $_POST["src"];
// delete image
unlink($src);
В коде файлов участвуют классы из laravel, но, я думаю, не составит труда найти подобные в интернете и немного изменить соответствующие участки.