This repository has been archived on 2026-06-20. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
wsh5485 7e47ce238b chore: 添加多个图片和资源文件
添加了管理后台所需的图片资源、Excel文件、安装程序以及设计相关的图片文件
2025-06-15 13:04:37 +08:00

180 lines
5.3 KiB
PHP

<?php
/*
* Created on 2016-11-2
*
* To change the template for this generated file go to
* Window - Preferences - PHPeclipse - PHP - Code Templates
*/
//制作缩略图
header("Content-type: text/html;charset=GB2312");
include "../tmpl/config.php";
require "include/db_mysql.php";
//error_reporting(E_ERROR | E_WARNING | E_PARSE);
$db=new DB_Sql;
$con = mysql_connect($dbhost,$dbuser,$dbpw);
if (!$con){
die("{\"code\":3, \"message\":\"数据库错误配置!\"}");
}
mysql_select_db($dbname) or die("{\"code\":3, \"message\":\"数据库错误配置!\"}");
$db->connect($dbhost,$dbuser,$dbpw,$dbname,"p");
//
function get_db_msg($query){
global $db;
$res=$db->query($query);
$msg=$db->fetch_array($res);
return $msg;
}
function make_mini_picture($srcFile,$dstFile,$size=200,$quality=80){
$data=GetImageSize($srcFile);
switch($data[2]){
case 1:
$im=@ImageCreateFromGIF($srcFile);
break;
case 2:
$im=@ImageCreateFromJPEG($srcFile);
break;
case 3:
$im=@ImageCreateFromPNG($srcFile);
break;
}
$srcW=ImageSX($im);
$srcH=ImageSY($im);
if($srcW<$size && $srcH<$size){
$dstW=$srcW;
$dstH=$srcH;
}else if($srcW>$srcH){
$dstW=$size;
$dstH=intval($srcH*$size/$srcW);
}else{
$dstH=$size;
$dstW=intval($srcW*$size/$srcH);
}
$ni=imagecreatetruecolor($dstW,$dstH);
imagecopyresampled($ni,$im,0,0,0,0,$dstW,$dstH,$srcW,$srcH);
ImageJpeg($ni,$dstFile,$quality);
}
//$path = 'new/Upload';
//print_r($_COOKIE['dir_path_u']);
//print_r($_FILES);
//单款
if($_COOKIE['dir_path_u']=='1'){
$path="../attachments/design/big";
$path2="../attachments/design/mini";
if (!empty($_FILES)) {
$tempFile = $_FILES['img-date']['tmp_name'];
$fileName= $_FILES['img-date']['name'];
if(!is_dir($path)){
mkdir($path);
}
if(!is_dir($path2)){
mkdir($path2);
}
$arr1=explode(".",$fileName);
$arr2=explode("_",$arr1[0]);
$tmp=get_db_msg("select id from web_kh where no='".$arr2[0]."'");
if($tmp["id"]>0 && $arr1[1]=="jpg"){
make_mini_picture($tempFile,$path."/".$fileName,800);
make_mini_picture($tempFile,$path2."/".$fileName,200);
echo "{\"code\":1, \"message\":\"上传成功!\"}";
}else{
echo "{\"code\":2, \"message\":\"上传失败,款号资料不存在或格式不正确!\"}";
}
//move_uploaded_file($tempFile,$path."/".$fileName);
}else{
echo "{\"code\":\"-1\",\"message\":\"上传失败!\"}";
}
//搭配
}else if($_COOKIE['dir_path_u']=='2'){
$tmp_session=get_db_msg("select _v from web_set where _k='order_session'");
$path_z="../attachments/dp/".$tmp_session["_v"];
$path="../attachments/dp/".$tmp_session["_v"]."/big";
$path2="../attachments/dp/".$tmp_session["_v"]."/mini";
if (!empty($_FILES)) {
$tempFile = $_FILES['img-date']['tmp_name'];
$fileName= $_FILES['img-date']['name'];
if(!is_dir($path_z)){
mkdir($path_z);
}
if(!is_dir($path)){
mkdir($path);
}
if(!is_dir($path2)){
mkdir($path2);
}
$arr1=explode(".",$fileName);
$tmp=get_db_msg("select id from web_kh_dp where pic='".$arr1[0]."' limit 0,1");
if($tmp["id"]>0 && $arr1[1]=="jpg"){
make_mini_picture($tempFile,$path."/".$fileName,800);
make_mini_picture($tempFile,$path2."/".$fileName,200);
echo "{\"code\":1, \"message\":\"上传成功!\"}";
}else{
echo "{\"code\":2, \"message\":\"上传失败,该图片在搭配资料不存在或格式不正确!\"}";
}
//move_uploaded_file($tempFile,$path."/".$fileName);
}else{
echo "{\"code\":\"-1\",\"message\":\"上传失败!\"}";
}
//陈列
}else if($_COOKIE['dir_path_u']=='3'){
$tmp_session=get_db_msg("select _v from web_set where _k='order_session'");
$path_z="../attachments/cl/".$tmp_session["_v"];
$path="../attachments/cl/".$tmp_session["_v"]."/big";
$path2="../attachments/cl/".$tmp_session["_v"]."/mini";
if (!empty($_FILES)) {
$tempFile = $_FILES['img-date']['tmp_name'];
$fileName= $_FILES['img-date']['name'];
if(!is_dir($path_z)){
mkdir($path_z);
}
if(!is_dir($path)){
mkdir($path);
}
if(!is_dir($path2)){
mkdir($path2);
}
$arr1=explode(".",$fileName);
$tmp=get_db_msg("select id from web_kh_cl where pic='".$arr1[0]."' limit 0,1");
if($tmp["id"]>0 && $arr1[1]=="jpg"){
make_mini_picture($tempFile,$path."/".$fileName,800);
make_mini_picture($tempFile,$path2."/".$fileName,200);
echo "{\"code\":1, \"message\":\"上传成功!\"}";
}else{
echo "{\"code\":2, \"message\":\"上传失败,该图片在陈列资料不存在或格式不正确!\"}";
}
//move_uploaded_file($tempFile,$path."/".$fileName);
}else{
echo "{\"code\":\"-1\",\"message\":\"上传失败!\"}";
}
//细节图
}else if($_COOKIE['dir_path_u']=='4'){
$path="../attachments/design/big";
$path2="../attachments/design/mini";
if (!empty($_FILES)) {
$tempFile = $_FILES['img-date']['tmp_name'];
$fileName= $_FILES['img-date']['name'];
if(!is_dir($path)){
mkdir($path);
}
if(!is_dir($path2)){
mkdir($path2);
}
$arr1=explode(".",$fileName);
$arr2=explode("-",$arr1[0]);
$tmp=get_db_msg("select id from web_kh where no='".$arr2[0]."'");
if($tmp["id"]>0 && $arr1[1]=="jpg"){
make_mini_picture($tempFile,$path."/".$fileName,800);
make_mini_picture($tempFile,$path2."/".$fileName,200);
echo "{\"code\":1, \"message\":\"上传成功!\"}";
}else{
echo "{\"code\":2, \"message\":\"上传失败,款号资料不存在或格式不正确!\"}";
}
//move_uploaded_file($tempFile,$path."/".$fileName);
}else{
echo "{\"code\":\"-1\",\"message\":\"上传失败!\"}";
}
}else{
echo "{\"code\":\"-1\",\"message\":\"上传失败!\"}";
}
?>