现在可以拖拉图片,粘贴图片了。可惜是base64代码,又写了个newstext字段函数,算是能用了。
//字段函数 newstext 保存base64图片 function user_saveBase64img($mid,$f,$isadd,$isq,$value,$cs){ global $public_r; //print_r($_POST);exit; //处理图片 $classid=(int)$_POST['classid']; $filepass=(int)$_POST['filepass']; $id=(int)$_POST['id']; preg_match_all('/\s+src\s?\=\s?[\'|"]([^\'|"]*)/imus', $value, $imgr); foreach($imgr[1] as $url){ if(!preg_match("#^data:image/(jpeg|gif|png);base64,([A-Za-z0-9+/]+)#i",$url, $matches))continue; $r[filetype]='.'.$matches[1]; $string=base64_decode($matches[2]); if(!$string)continue; //文件名 $r['insertfile']=ReturnDoTranFilename($file_name,$classid); $r['filename']=$r[insertfile].$r['filetype']; //日期目录 $r['filepath']=FormatFilePath($classid,$mynewspath,0); $filepath=$r[filepath]?$r[filepath].'/':$r[filepath]; //存放目录 $fspath=ReturnFileSavePath($classid); $r['savepath']=eReturnEcmsMainPortPath().$fspath['filepath'].$filepath;//moreport //附件地址 $r['url']=$fspath['fileurl'].$filepath.$r['filename']; //缩图文件 //$r['name']=$r[savepath]."small".$r['insertfile']; //附件文件 $r['yname']=$r['savepath'].$r['filename']; WriteFiletext_n($r['yname'],$string); $r[filesize]=@filesize($r['yname']); //会写到value $value=str_replace($url,$r['url'],$value); //写入数据库 $no=$r['filename']; $type=1; //图片 $fstb=$public_r['filedeftb']; $modtype=0; // 0信息 5公共 6会员 $sql=eInsertFileTable($r['filename'],$r['filesize'],$r['filepath'],$username,$classid,$no,$type,$id,$filepass,$public_r['fpath'],0,$modtype,$fstb); } return $value; }
|