if ($_FILES["images"]["error"][$i] > 0) { //echo "Return Code: " . $_FILES["images"]["error"][$i] . "<br />"; } else { if (file_exists($url . $_FILES["images"]["name"][$i])) { //echo $_FILES["images"]["name"][$i] . " đã tồn tại. "."<br />"; } else { $arrPartImage = explode('.', $_FILES["images"]["name"][$i]); // Get image extension $imgExt = array_pop($arrPartImage); // Get image not extension $img = preg_replace('/(.*)(_\\d+x\\d+)/', '$1', implode('.', $arrPartImage)); $img = changeTitle($img); $img = $img . "_" . time(); $name = "{$img}.{$imgExt}"; if (move_uploaded_file($_FILES["images"]["tmp_name"][$i], $url . $name) == true) { resizeHoang($url . $name, -1, -1, $name, $url); } $url_image_tmp = $url . $name; $url_image = str_replace('../', '', $url) . $name; } } } $checked = $i == 0 && $is_update != 1 ? "checked='checked'" : ""; $html .= '<div class="col-md-2 image_upload"><img src="' . $url_image_tmp . '" width="150"><br /> <p style="width:30%;float:left;text-align:right;margin-top:10px"><span style="cursor:pointer" data-value="' . $url_image . '">Xóa</span></p> </div>'; $str_image .= $url_image . ";"; } $html .= "</div>"; $arrReturn['html'] = $html; $arrReturn['str_image'] = '<input type="hidden" value="' . $str_image . '" name="str_image" id="str_image" />';
$img = preg_replace('/(.*)(_\\d+x\\d+)/', '$1', implode('.', $arrPartImage)); $img = changeTitle($img); $img = $img . "_" . time(); $name = "{$img}.{$imgExt}"; $name_1 = "{$img}_{$width_1}x{$height_1}.{$imgExt}"; if ($mod != 'banner') { $name_2 = "{$img}_{$width_2}x{$height_2}.{$imgExt}"; $name_3 = "{$img}_{$width_3}x{$height_3}.{$imgExt}"; } else { $name = $name_1; } if (move_uploaded_file($_FILES["images"]["tmp_name"][$i], $url . $name) == true) { if ($mod != 'banner') { resizeHoang($url . $name, $width_1, $height_1, $name_1, $url); resizeHoang($url . $name, $width_2, $height_2, $name_2, $url); resizeHoang($url . $name, $width_3, $height_3, $name_3, $url); } $count++; $strHinhAnh .= str_replace("../", "", $url) . $name_1 . ";"; $name_2 = $mod == "banner" ? $name_1 : $name_2; $arrRes['text'] .= "<li style='float:left;display:inline;margin-right:10px;text-align:center'>\t\t\t\t\n\t\t\t\t\t<img src='" . "../" . str_replace("../", "", $url) . $name_2 . "' width='166' /><br />\t\t\t\t\n\t\t\t\t\t</li>"; } } } } $arrRes['text'] .= "</ul></div>"; } if ($count > 0) { $strHinhAnh = substr($strHinhAnh, 0, -1); $arrRes['thongbao'] = "Upload thành công {$count} images"; $arrRes['str_hinhanh'] = "<input type='hidden' id='str_hinh_anh' name='str_hinh_anh' value='" . $strHinhAnh . "'>";
} else { if (file_exists($url . $_FILES["images"]["name"][$i])) { //echo $_FILES["images"]["name"][$i] . " đã tồn tại. "."<br />"; } else { $arrPartImage = explode('.', $_FILES["images"]["name"][$i]); // Get image extension $imgExt = array_pop($arrPartImage); // Get image not extension $img = preg_replace('/(.*)(_\\d+x\\d+)/', '$1', implode('.', $arrPartImage)); $img = changeTitle($img); $img = $img . "_" . time(); $name = "{$img}.{$imgExt}"; $name1 = "{$img}_2.{$imgExt}"; if (move_uploaded_file($_FILES["images"]["tmp_name"][$i], $url . $name) == true) { resizeHoang($url . $name, -1, -1, $name, $url); resizeHoang($url . $name, -1, -1, $name1, $url, 2); } $url_image_tmp = $url . $name; $url_image = str_replace('../', '', $url) . $name; } } } $checked = $i == 0 && $is_update != 1 ? "checked='checked'" : ""; $html .= '<div class="col-md-2 image_upload"><img src="' . $url_image_tmp . '" width="150"><br /> <p style="width:70%;float:left;margin-top:10px"><input type="radio" ' . $checked . ' name="image_url" value="' . $url_image . '" /> Ảnh đại diện</p> <p style="width:30%;float:left;text-align:right;margin-top:10px"><span style="cursor:pointer" data-value="' . $url_image . '">Xóa</span></p> </div>'; $str_image .= $url_image . ";"; } $html .= "</div>"; $arrReturn['html'] = $html;
// Get image extension $imgExt = array_pop($arrPartImage); // Get image not extension $img = preg_replace('/(.*)(_\\d+x\\d+)/', '$1', implode('.', $arrPartImage)); $img = changeTitle($img); $img = $img . "_" . time(); $name = "{$img}.{$imgExt}"; $name6 = "{$img}_6.{$imgExt}"; $name4 = "{$img}_4.{$imgExt}"; $name2 = "{$img}_2.{$imgExt}"; $name1 = "{$img}_690x460.{$imgExt}"; if (move_uploaded_file($_FILES["myfile"]["tmp_name"][$i], $url . $name) == true) { resizeHoang($url . $name, -1, -1, $name, $url); resizeHoang($url . $name, 690, 460, $name1, $url, -1); resizeHoang($url . $name, -1, -1, $name2, $url, 2); resizeHoang($url . $name, -1, -1, $name4, $url, 4); } $url_image_tmp = $url . $name4; $url_image = str_replace('../', '', $url) . $name; } } } $checked = $i == 0 && $is_update != 1 ? "checked='checked'" : ""; $html .= '<div class="col-md-2 image_upload" style="border: 1px solid #CCC; padding: 10px;margin-right:2px;min-height:240px"><img src="' . $url_image_tmp . '" width="150"><br /> <p style="width:70%;float:left;margin-top:10px"><input type="radio" ' . $checked . ' name="image_url" value="' . $url_image . '" /> Ảnh đại diện</p> <p style="width:30%;float:left;text-align:right;margin-top:10px"><span style="cursor:pointer" data-value="' . $url_image . '">Xóa</span></p> </div>'; $str_image .= $url_image . ";"; } $html .= "</div>"; $arrReturn['html'] = $html;