40 lines
2.0 KiB
PHP
40 lines
2.0 KiB
PHP
|
|
<?php
|
||
|
|
require_once($_SERVER['DOCUMENT_ROOT']."/config.php");
|
||
|
|
|
||
|
|
include $_SERVER['DOCUMENT_ROOT'] . '/import/obj/ImportRecord.php';
|
||
|
|
include $_SERVER['DOCUMENT_ROOT'] . '/import/obj/BlockImage.php';
|
||
|
|
|
||
|
|
$result = ""; $result_photos = "";
|
||
|
|
for ($i=0; $i<count($_FILES['blockRealPhoto']['name']); $i++) {
|
||
|
|
if ($_FILES['blockRealPhoto']['error'][$i] == 0) {
|
||
|
|
$ext = strtolower(pathinfo($_FILES['blockRealPhoto']['name'][$i], PATHINFO_EXTENSION));
|
||
|
|
$name = md5($_FILES['blockRealPhoto']['tmp_name'][$i].time()).".".$ext;
|
||
|
|
|
||
|
|
if (!is_dir($_SERVER['DOCUMENT_ROOT'] . "/block_images")) {
|
||
|
|
mkdir($_SERVER['DOCUMENT_ROOT'] . "/block_images");
|
||
|
|
}
|
||
|
|
|
||
|
|
if (!is_dir($_SERVER['DOCUMENT_ROOT'] . "/block_images/real")) {
|
||
|
|
mkdir($_SERVER['DOCUMENT_ROOT'] . "/block_images/real");
|
||
|
|
}
|
||
|
|
|
||
|
|
// $photo="/block_images/".$new_path;
|
||
|
|
$photo="/block_images/real/".$name;
|
||
|
|
|
||
|
|
move_uploaded_file($_FILES['blockRealPhoto']['tmp_name'][$i],$_SERVER['DOCUMENT_ROOT'].$photo);
|
||
|
|
|
||
|
|
$image = BlockImage::createImage($_POST['blockId'], $photo, 1);
|
||
|
|
|
||
|
|
$result_photos .= "<div class=\'col-md-1 del_photo\' style=\'margin-bottom: 7px;background:url(http://" . $_SERVER['SERVER_NAME'] . "$photo) no-repeat;background-size:cover;background-position:center;\'><div class=\'deleteBlockImage\' data-id=\'" .$image->id . "\' style=\'background-image: url(/images/del_Icon.png); width: 37px; height: 48px\'></div></div>";
|
||
|
|
} else {
|
||
|
|
$result .= "Превышен размер файла ".$_FILES['blockRealPhoto']['name'][$i];
|
||
|
|
}
|
||
|
|
}
|
||
|
|
?>
|
||
|
|
<script>
|
||
|
|
if(parent.document.getElementById('block-real-images-container'))
|
||
|
|
parent.document.getElementById('block-real-images-container').style.backgroundImage='';
|
||
|
|
parent.document.getElementById('image-block-real-result').innerHTML+='<?php echo $result_photos.$result; ?>';
|
||
|
|
parent.document.getElementById('block-real-images-form').target = '';
|
||
|
|
parent.document.getElementById('block-real-images-form').action = '';
|
||
|
|
</script>
|