<?php
require dirname(__FILE__).'/include/Inc.php';
require dirname(__FILE__).'/include/Sys_session.php';
require dirname(__FILE__).'/include/Upload_fun.php';
$uptypes=array(
'image/jpg',
'image/jpeg',
'image/png',
'image/pjpeg',
'image/gif',
'image/bmp',
'image/x-png'
);
$_filepaths = Replace_Text($_POST["filepaths"]);
$_EditName = Replace_Text($_POST["EditName"]);
$_FormName = Replace_Text($_POST["FormName"]);
$_PPID = Replace_Text($_POST["PPID"]);
$_act = Replace_Text($_POST["act"]);
$max_file_size=2000000; //上传文件大小限制, 单位BYTE
$destination_folder=$_filepaths; //上传文件路径
$watermark=1; //是否附加水印(1为加水印,其他为不加水印);
$watertype="img"; //img代表以图片方式,text代表以文字方式添加水印
$waterposition=7; //(1为左下角,2为右下角,3为左上角,4为右上角,5为居中);
$waterstring="0917e.com"; //水印字符串
$TextColor =""; //水印颜色
$fontType =""; //水印字体
$waterimg="images/LOGO.png"; //水印图片
$cls_ftp=0;
if ($_act == 'uploadfile')
{
if (!is_uploaded_file($_FILES["file1"][tmp_name]))
//是否存在文件
{
echo "图片不存在!";
exit;
}
$file = $_FILES["file1"];
if($max_file_size < $file["size"])
//检查文件大小
{
echo "文件太大!";
exit;
}
if(!in_array($file["type"], $uptypes))
//检查文件类型
{
echo "文件类型不符!".$file["type"];
exit;
}
if(!file_exists($destination_folder))
{
mkdir($destination_folder);
}
$filename=$file["tmp_name"];
$image_size = getimagesize($filename);
$pinfo=pathinfo($file["name"]);
$ftype=$pinfo['extension'];
$destination = $destination_folder.time().".".$ftype;
if (file_exists($destination) && $overwrite != true)
{
echo "同名文件已经存在了";
exit;
}
if(!move_uploaded_file ($filename, $destination))
{
echo "移动文件出错";
exit;
}
$pinfo=pathinfo($destination);
$fname=$pinfo[basename];
//echo " <font color=red>已经成功上传</font><br>文件名: <font color=blue>".$destination_folder.$fname."</font><br>";
//echo " 宽度:".$image_size[0];
//echo " 长度:".$image_size[1];
//echo "<br> 大小:".$file["size"]." bytes";
if($watermark==1) {
setWater($destination_folder.$fname,$waterimg,$waterstring,$TextColor,$waterposition,$fontType,$watertype);
}
if($cls_ftp==1){
$picname=$destination_folder.$fname;
$cls_ftp_path=$fname;
$ftp_server="FTP地址";
$con=ftp_connect($ftp_server);
ftp_login($con,"username","password");
$tempstate=ftp_put($con,$cls_ftp_path,$picname,FTP_BINARY);//以二进制方式上传文件
if($tempstate){
//unlink删除www服务器上的图片当然也可以保留
echo "<table width='100%' border='0' cellspacing='0' cellpadding='0'>";
echo "<tr>";
echo "<td valign='middle' align='center'>" ;
echo ("<img src='images/suss.gif' />");
echo ("<span style=' margin:auto;font-family:Verdana, Geneva, sans-serif; font-size:16px; color:#900;'><br>上传成功请不要修改上传好的图片地址</span>");
echo "</td>";
echo "</tr>";
echo "</table>";
}else{
echo "上传未成功";
exit();
}
ftp_quit($con);//
}
echo "<table width='100%' border='0' cellspacing='0' cellpadding='0'>";
echo "<tr>";
echo "<td valign='middle' align='center'>" ;
echo ("<img src='images/suss.gif' />");
echo ("<span style=' margin:auto;font-family:Verdana, Geneva, sans-serif; font-size:16px; color:#900;'><br>上传成功请不要修改上传好的图片地址</span>");
echo "</td>";
echo "</tr>";
echo "</table>";
}
_close();
?>
<script language="javascript">
var dg = frameElement.lhgDG;
window.onload=function()
{
dg.curWin.document.getElementById("pic1").value=("<?php echo $fname?>");
dg.addBtn( 'close', '上传成功', dg.cancel );
dg.reDialogSize(450,200);
}
</script>