图片上传,图片剪切jquery.imgareaselect

---恢复内容开始---

<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta charset="utf-8" />
<title>广告设置</title>
<%@include file="/common/common.jsp" %>
<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/static/jquery.imgareaselect-0.9.10/css/imgareaselect-default.css" />
<script type="text/javascript" src="${pageContext.request.contextPath}/static/jquery.imgareaselect-0.9.10/scripts/jquery.imgareaselect.pack.js"></script>
</head>
<body>
<div class="wrapper details" id="js_layout">
<div class="pad10" id="details_edit" data-options="region:‘center‘">
<table class="forms">
<tbody>
<tr>
<td class="right"><i class="require">*</i>广告图设置方式:</td>
<td><input type="radio" value="1" name="pic" checked="checked" onclick="$(‘.tr1‘).show();$(‘#tr2‘).hide()"/>上传图片
<input type="radio" value="0" name="pic" onclick="$(‘.tr1‘).hide();$(‘#tr2‘).show()"/>设置图片超链接
</td>
</tr>
<tr class="tr1">
<td class="right"><i class="require">*</i>上传图片:</td>
<td>
<form id="form2" method="post" enctype="multipart/form-data">
<input type="file" style="height:22px;" name="advimage" id="advimage" onchange="validateImage();"/>
</form>
</td>
</tr>
<tr class="tr1">
<td class="right"><i class="require">*</i>图片剪切:</td>
<td>
<form id="form1" method="post" enctype="multipart/form-data" >
<img src="" id="left" onclick="imgAreaSelect();">
<input type="hidden" id="x1" value=""/>
<input type="hidden" id="x2" value=""/>
<input type="hidden" id="y1" value=""/>
<input type="hidden" id="y2" value=""/>
<input type="hidden" id="w" value=""/>
<input type="hidden" id="h" value=""/>
<input type="button" value="剪切" onclick="cutImage()"/>
</form>
</td>
</tr>
<tr class="tr1">
<td class="right"><i class="require">*</i>图片预览</td>
<td>
<form id="form3" method="post" enctype="multipart/form-data" >
<img src="" id="leftcut">
<input type="hidden" id="currentPath" value="" name="currentPath">
</form>
</td>
</tr>
<tr id="tr2" style="display: none;">
<td class="right"><i class="require">*</i>公告图超链接:</td>
<td><input type="text" name="picurl" id="picUrl" value="http://js.86269191.com/hgzr/img/22.gif" class="txt easyui-validatebox" data-options="required:true,validType:[‘titleInput‘,‘titlelength[200]‘]"/>
</td>
</tr>
<tr>
<td class="right"><i class="require">*</i>超链接:</td>
<td><input type="text" name="url" id="url" value="http://www.90tuku.com/" class="txt easyui-validatebox" data-options="required:true,validType:[‘titleInput‘,‘titlelength[200]‘]"/>
</td>
</tr>
<tr>
<td class="right"><i class="require">*</i>广告存放位置:</td>
<td><input type="radio" value="left" name="position" checked="checked" />左侧广告
<input type="radio" value="right" name="position"/>右侧广告
</td>
</tr>
</tbody>
</table>
</div>
<!-- <div id="cutImageDiv"> -->
<!-- <div id="cutImageClose">关闭</div> -->
<!-- <div style="margin:0;auto"> -->
<!-- <img src="" id="right" onclick="imgAreaSelect();"> -->
<!-- </div> -->
<!-- </div> -->
<div data-options="region:‘south‘,collapsible:false,height:50" class="noborder hidden">
<div class="ftbutton border-n">
<ul class="lists rf">
<li><button id="_submit" class="button" type="button">上传广告</button></li>
</ul>
</div>
</div>
</div>
<script type="text/javascript" charset="utf-8">
function cutImage(){
var currentPath = $("#currentPath").val();
$.ajax({
type: "POST",
url: "${contextPath}/baAdmin/cutImage.htmls",
data: "x1=" + $("#x1").val()+"&x2="+$("#x2").val()+"&y1="+$("#y1").val()+"&y2="+$("#y2").val()+"&w="+$("#w").val()+"&h="+$("#h").val()+"&currentPath="+currentPath,
success: function(msg){
var json = $.parseJSON(msg);
if(json.success==‘success‘){
$("#currentPath").val(json.currentPath);
$(‘#leftcut‘).attr("src",json.currentPath);
}
}
});
// 这里是利用的dwr框架直接调用后台方法,以及使用后台传回的值
// 这个方法就是利用坐标宽高进行切图,事实上这时候的原图已经在服务器了,所以我们只需要知道他的相对路径,即currentPath
// ReleaseService.cutImage(list, currentPath, function(value){

// document.getElementById("currentPath").value = value;
// }
// );

// var bgObj=document.getElementById("bgDiv");
// var msgObj=document.getElementById("cutImageDiv");
// bgObj.style.display = msgObj.style.display = "none";
// piso.cancelSelection();
// haveImage = 1;
// $(‘#msHaveImage‘).show();
//$(".imgareaselect-outer").hide();
//$(".imgareaselect-selection").parent().hide();

}
function validateImage(){
var imageVal = $(‘#advimage‘).val();
var imageType = imageVal.substr(imageVal.indexOf(‘.‘),imageVal.length);
if(!/.(gif|jp|jpeg|JPG|PNG|png|jpg)$/.test(imageType)){
$.messager.alert(‘警告‘,‘图片类型必须是.jpeg,png,jpg中的一种!‘,‘info‘);
return false;
}
//提交表单
$("#form2").form(‘submit‘,
{
url:"${contextPath}/baAdmin/uploadImageDemo.htmls",
onSubmit:function(){return $(this).form(‘validate‘); },
success : function(d) {
var json = $.parseJSON(d);
if (json.success==‘success‘) {
$(‘#left‘).imgAreaSelect({
x1:0,y1:0,x2:50,y2:50,onSelectEnd:preview,
resizable:false,
instance:true,
persistent:true
});
$(‘#left‘).attr(‘src‘,json.tempPath);
$(‘#currentPath‘).val(json.tempPath);
// ajaxLoadEnd();
// $.messager.alert(‘警告‘,‘备份成功!‘,‘info‘);
}else{
// $.messager.alert(‘警告‘,‘执行失败!‘,‘error‘);
}
}
});
}
// function uploadImage(){
// var imageVal = $(‘#advimage‘).val();
// var imageType = imageVal.substr(imageVal.indexOf(‘.‘),imageVal.length);
// if(!/.(gif|jp|jpeg|JPG|PNG|png)$/.test(imageType)){
// $.messager.alert(‘警告‘,‘图片类型必须是.jpeg,png,jpg中的一种!‘,‘info‘);
// return false;
// }
// $.ajaxFileUpload({
// url:‘${pageContext.request.contextPath}/baAdmin/uploadImage‘,//处理图片脚本
// secureuri :false,
// fileElementId :‘advimage‘,//file控件id
// dataType : ‘json‘,
// success : function (data, status){
// $(‘#photo‘).imgAreaSelect({
// x1:0,y1:0,x2:480,y2:520,onSelectEnd:preview,
// resizable:false,
// instance:true,
// persistent:true
// });
// $(‘#photo‘).attr(‘src‘,data.tempPath);
// },
// error: function(data, status, e){
// alert(e);
// }
// });
// }
function preview(img,selection){
$(‘#x1‘).val(selection.x1);
$(‘#x2‘).val(selection.x2);
$(‘#y1‘).val(selection.y1);
$(‘#y2‘).val(selection.y2);
$(‘#w‘).val(selection.width);
$(‘#h‘).val(selection.height);
}
// function ajaxLoading(){
// $("<div class=\"datagrid-mask\"></div>").css({display:"block",width:"100%",height:$(window).height()}).appendTo("body");
// $("<div class=\"datagrid-mask-msg\"></div>").html("正在处理,请稍候。。。").appendTo("body").css({display:"block",left:($(document.body).outerWidth(true) - 190) / 2,top:($(window).height() - 45) / 2});
// }
// function ajaxLoadEnd(){
// $(".datagrid-mask").remove();
// $(".datagrid-mask-msg").remove();
// }
jQuery(function($){
$("#js_layout").layout({fit:true});
$("#_submit").click( function () {
var pic = $(‘input:radio[name="pic"]:checked‘).val();
var position = $(‘input:radio[name="position"]:checked‘).val();
var url = $(‘#url‘).val();
var picUrl = $(‘#picUrl‘).val();
var file = $(‘#advimage‘).val();
if(pic==‘1‘){
if(file==""){
$.messager.alert(‘提示‘,‘为选择上传图片!!!‘,‘info‘);
return ;
}
}
//提交表单
$("#form3").form(‘submit‘,
{
url:"${contextPath}/baAdmin/imageUploadFinlly.htmls?position="+position+"&pic="+pic+"&url="+url+"&picurl="+picUrl,
onSubmit:function(){return $(this).form(‘validate‘); },
success : function(d) {
var json = $.parseJSON(d);
if (json.success==‘success‘) {
$.messager.alert(‘提示‘,‘左侧广告设置成功!‘,‘info‘);
}
}
});
});
});
</script>
</body>
</html>

---恢复内容结束---

<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta charset="utf-8" />
<title>广告设置</title>
<%@include file="/common/common.jsp" %>
<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/static/jquery.imgareaselect-0.9.10/css/imgareaselect-default.css" />
<script type="text/javascript" src="${pageContext.request.contextPath}/static/jquery.imgareaselect-0.9.10/scripts/jquery.imgareaselect.pack.js"></script>
</head>
<body>
<div class="wrapper details" id="js_layout">
<div class="pad10" id="details_edit" data-options="region:‘center‘">
<table class="forms">
<tbody>
<tr>
<td class="right"><i class="require">*</i>广告图设置方式:</td>
<td><input type="radio" value="1" name="pic" checked="checked" onclick="$(‘.tr1‘).show();$(‘#tr2‘).hide()"/>上传图片
<input type="radio" value="0" name="pic" onclick="$(‘.tr1‘).hide();$(‘#tr2‘).show()"/>设置图片超链接
</td>
</tr>
<tr class="tr1">
<td class="right"><i class="require">*</i>上传图片:</td>
<td>
<form id="form2" method="post" enctype="multipart/form-data">
<input type="file" style="height:22px;" name="advimage" id="advimage" onchange="validateImage();"/>
</form>
</td>
</tr>
<tr class="tr1">
<td class="right"><i class="require">*</i>图片剪切:</td>
<td>
<form id="form1" method="post" enctype="multipart/form-data" >
<img src="" id="left" onclick="imgAreaSelect();">
<input type="hidden" id="x1" value=""/>
<input type="hidden" id="x2" value=""/>
<input type="hidden" id="y1" value=""/>
<input type="hidden" id="y2" value=""/>
<input type="hidden" id="w" value=""/>
<input type="hidden" id="h" value=""/>
<input type="button" value="剪切" onclick="cutImage()"/>
</form>
</td>
</tr>
<tr class="tr1">
<td class="right"><i class="require">*</i>图片预览</td>
<td>
<form id="form3" method="post" enctype="multipart/form-data" >
<img src="" id="leftcut">
<input type="hidden" id="currentPath" value="" name="currentPath">
</form>
</td>
</tr>
<tr id="tr2" style="display: none;">
<td class="right"><i class="require">*</i>公告图超链接:</td>
<td><input type="text" name="picurl" id="picUrl" value="http://js.86269191.com/hgzr/img/22.gif" class="txt easyui-validatebox" data-options="required:true,validType:[‘titleInput‘,‘titlelength[200]‘]"/>
</td>
</tr>
<tr>
<td class="right"><i class="require">*</i>超链接:</td>
<td><input type="text" name="url" id="url" value="http://www.90tuku.com/" class="txt easyui-validatebox" data-options="required:true,validType:[‘titleInput‘,‘titlelength[200]‘]"/>
</td>
</tr>
<tr>
<td class="right"><i class="require">*</i>广告存放位置:</td>
<td><input type="radio" value="left" name="position" checked="checked" />左侧广告
<input type="radio" value="right" name="position"/>右侧广告
</td>
</tr>
</tbody>
</table>
</div>
<!-- <div id="cutImageDiv"> -->
<!-- <div id="cutImageClose">关闭</div> -->
<!-- <div style="margin:0;auto"> -->
<!-- <img src="" id="right" onclick="imgAreaSelect();"> -->
<!-- </div> -->
<!-- </div> -->
<div data-options="region:‘south‘,collapsible:false,height:50" class="noborder hidden">
<div class="ftbutton border-n">
<ul class="lists rf">
<li><button id="_submit" class="button" type="button">上传广告</button></li>
</ul>
</div>
</div>
</div>
<script type="text/javascript" charset="utf-8">
function cutImage(){
var currentPath = $("#currentPath").val();
$.ajax({
type: "POST",
url: "${contextPath}/baAdmin/cutImage.htmls",
data: "x1=" + $("#x1").val()+"&x2="+$("#x2").val()+"&y1="+$("#y1").val()+"&y2="+$("#y2").val()+"&w="+$("#w").val()+"&h="+$("#h").val()+"&currentPath="+currentPath,
success: function(msg){
var json = $.parseJSON(msg);
if(json.success==‘success‘){
$("#currentPath").val(json.currentPath);
$(‘#leftcut‘).attr("src",json.currentPath);
}
}
});
// 这里是利用的dwr框架直接调用后台方法,以及使用后台传回的值
// 这个方法就是利用坐标宽高进行切图,事实上这时候的原图已经在服务器了,所以我们只需要知道他的相对路径,即currentPath
// ReleaseService.cutImage(list, currentPath, function(value){

// document.getElementById("currentPath").value = value;
// }
// );

// var bgObj=document.getElementById("bgDiv");
// var msgObj=document.getElementById("cutImageDiv");
// bgObj.style.display = msgObj.style.display = "none";
// piso.cancelSelection();
// haveImage = 1;
// $(‘#msHaveImage‘).show();
//$(".imgareaselect-outer").hide();
//$(".imgareaselect-selection").parent().hide();

}
function validateImage(){
var imageVal = $(‘#advimage‘).val();
var imageType = imageVal.substr(imageVal.indexOf(‘.‘),imageVal.length);
if(!/.(gif|jp|jpeg|JPG|PNG|png|jpg)$/.test(imageType)){
$.messager.alert(‘警告‘,‘图片类型必须是.jpeg,png,jpg中的一种!‘,‘info‘);
return false;
}
//提交表单
$("#form2").form(‘submit‘,
{
url:"${contextPath}/baAdmin/uploadImageDemo.htmls",
onSubmit:function(){return $(this).form(‘validate‘); },
success : function(d) {
var json = $.parseJSON(d);
if (json.success==‘success‘) {
$(‘#left‘).imgAreaSelect({
x1:0,y1:0,x2:50,y2:50,onSelectEnd:preview,
resizable:false,
instance:true,
persistent:true
});
$(‘#left‘).attr(‘src‘,json.tempPath);
$(‘#currentPath‘).val(json.tempPath);
// ajaxLoadEnd();
// $.messager.alert(‘警告‘,‘备份成功!‘,‘info‘);
}else{
// $.messager.alert(‘警告‘,‘执行失败!‘,‘error‘);
}
}
});
}
// function uploadImage(){
// var imageVal = $(‘#advimage‘).val();
// var imageType = imageVal.substr(imageVal.indexOf(‘.‘),imageVal.length);
// if(!/.(gif|jp|jpeg|JPG|PNG|png)$/.test(imageType)){
// $.messager.alert(‘警告‘,‘图片类型必须是.jpeg,png,jpg中的一种!‘,‘info‘);
// return false;
// }
// $.ajaxFileUpload({
// url:‘${pageContext.request.contextPath}/baAdmin/uploadImage‘,//处理图片脚本
// secureuri :false,
// fileElementId :‘advimage‘,//file控件id
// dataType : ‘json‘,
// success : function (data, status){
// $(‘#photo‘).imgAreaSelect({
// x1:0,y1:0,x2:480,y2:520,onSelectEnd:preview,
// resizable:false,
// instance:true,
// persistent:true
// });
// $(‘#photo‘).attr(‘src‘,data.tempPath);
// },
// error: function(data, status, e){
// alert(e);
// }
// });
// }
function preview(img,selection){
$(‘#x1‘).val(selection.x1);
$(‘#x2‘).val(selection.x2);
$(‘#y1‘).val(selection.y1);
$(‘#y2‘).val(selection.y2);
$(‘#w‘).val(selection.width);
$(‘#h‘).val(selection.height);
}
// function ajaxLoading(){
// $("<div class=\"datagrid-mask\"></div>").css({display:"block",width:"100%",height:$(window).height()}).appendTo("body");
// $("<div class=\"datagrid-mask-msg\"></div>").html("正在处理,请稍候。。。").appendTo("body").css({display:"block",left:($(document.body).outerWidth(true) - 190) / 2,top:($(window).height() - 45) / 2});
// }
// function ajaxLoadEnd(){
// $(".datagrid-mask").remove();
// $(".datagrid-mask-msg").remove();
// }
jQuery(function($){
$("#js_layout").layout({fit:true});
$("#_submit").click( function () {
var pic = $(‘input:radio[name="pic"]:checked‘).val();
var position = $(‘input:radio[name="position"]:checked‘).val();
var url = $(‘#url‘).val();
var picUrl = $(‘#picUrl‘).val();
var file = $(‘#advimage‘).val();
if(pic==‘1‘){
if(file==""){
$.messager.alert(‘提示‘,‘为选择上传图片!!!‘,‘info‘);
return ;
}
}
//提交表单
$("#form3").form(‘submit‘,
{
url:"${contextPath}/baAdmin/imageUploadFinlly.htmls?position="+position+"&pic="+pic+"&url="+url+"&picurl="+picUrl,
onSubmit:function(){return $(this).form(‘validate‘); },
success : function(d) {
var json = $.parseJSON(d);
if (json.success==‘success‘) {
$.messager.alert(‘提示‘,‘左侧广告设置成功!‘,‘info‘);
}
}
});
});
});
</script>
</body>
</html>

/**
* springmvc 上传文件
* @return
*/
@ResponseBody
@RequestMapping("/uploadImageDemo")
public Object uploadImageDemo(@RequestParam(value="advimage",required=false) MultipartFile file, HttpServletRequest request, ModelMap model){
Map<String, Object> resultMap = new HashMap<String, Object>();
System.out.println("开始");
String path = request.getSession().getServletContext().getRealPath("upload");
// String cutpath = request.getSession().getServletContext().getRealPath("cutUpload");
String fileName = file.getOriginalFilename();
System.out.println(path);
File targetFile = new File(path, fileName);
if(!targetFile.exists()){
targetFile.mkdirs();
}

//保存
try {
file.transferTo(targetFile);
} catch (Exception e) {
e.printStackTrace();
}
resultMap.put("tempPath", request.getContextPath()+"/upload/"+fileName);
resultMap.put("success", "success");
return resultMap;
}

@ResponseBody
@RequestMapping("/cutImage")
public Object cutImage(HttpServletRequest request, HttpServletResponse response) {
Map<String, Object> restMap = new HashMap<String, Object>();
String x11 = request.getParameter("x1");
String x22 = request.getParameter("x2");
String y11 = request.getParameter("y1");
String y22 = request.getParameter("y2");
String ww= request.getParameter("w");
String hh = request.getParameter("h");
String path = request.getParameter("currentPath");
int x1 = Integer.parseInt(x11);
int x2 = Integer.parseInt(x22);
int y1 = Integer.parseInt(y11);
int y2 = Integer.parseInt(y22);
int w = Integer.parseInt(ww);
int h = Integer.parseInt(hh);
if(w <= 0)
w = 120;
if(h<=0)
h = 120;
if(x1<0)
x1 = 0;
if(y1<0)
y1 = 0;

//File file = new File(request.getSession().getServletContext().getRealPath(path));

// path = path.substring(2);

SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
String file_ext = path.substring(path.indexOf("."),path.length());
String uploadpath = request.getSession().getServletContext().getRealPath("upload");
File file = new File(request.getSession().getServletContext().getRealPath(uploadpath));
String imageName =df.format(new Date())+UUIDUtils.getUUID32() + file_ext;
String newFile = uploadpath +"/"+imageName;

//切图操作
abscut(request.getSession().getServletContext().getRealPath(path), newFile, x1, y1, w, h);
// File targetFile = new File(path, fileName);
// if(!targetFile.exists()){
// targetFile.mkdirs();
// }
//
// //保存
// try {
// file.transferTo(targetFile);
// } catch (Exception e) {
// e.printStackTrace();
// }
restMap.put("success", "success");
restMap.put("currentPath", request.getContextPath()+"/upload/"+imageName);
return restMap;
// return BusinessConstants.TEMP_RELATIVE_PICTURE_PATH + imageName;
}

public static void abscut(String srcImageFile,String desImageFile, int x, int y,int width, int height) {
try {
Image img;
ImageFilter cropFilter;
File srcFile = new File(srcImageFile);
//String fileName = srcFile.getName();
String ext = getExtension(srcImageFile);
if(ext==null)ext="jpg";
// 读取源图像
BufferedImage bi = ImageIO.read(srcFile);
int srcWidth = bi.getWidth(); // 源图宽度
int srcHeight = bi.getHeight(); // 源图高度
if (srcWidth >= width && srcHeight >= height) {
BufferedImage tag;
Image image = bi.getScaledInstance(srcWidth, srcHeight,Image.SCALE_DEFAULT);
// 四个参数分别为图像起点坐标和宽高
// 即: CropImageFilter(int x,int y,int width,int height)
cropFilter = new CropImageFilter(x, y, width, height);
img = Toolkit.getDefaultToolkit().createImage(new FilteredImageSource(image.getSource(), cropFilter));
int type = BufferedImage.TYPE_INT_RGB;
if("gif".equalsIgnoreCase(ext)||"png".equalsIgnoreCase(ext)){
type = BufferedImage.TYPE_INT_ARGB;
}
tag = new BufferedImage(width, height,type);
Graphics2D g = (Graphics2D)tag.getGraphics();

g.setRenderingHint(RenderingHints.KEY_INTERPOLATION,RenderingHints.VALUE_INTERPOLATION_BILINEAR);
g.drawImage(img, 0, 0, null); // 绘制剪切后的图
g.dispose();

ImageIO.write(tag,ext, new File(desImageFile));
srcFile.delete();//删除原图
}
} catch (Exception e) {
e.printStackTrace();
}
}

public static String getExtension(String srcImageFile) {
String ext = null;
if(srcImageFile!=null && srcImageFile.lastIndexOf(".")>-1){
ext = srcImageFile.substring(srcImageFile.lastIndexOf(".")+1);
}
return ext;
}

时间: 2024-10-25 15:25:03

图片上传,图片剪切jquery.imgareaselect的相关文章

spring mvc 图片上传,图片压缩、跨域解决、 按天生成目录 ,删除,限制为图片代码等相关配置

spring mvc 图片上传,跨域解决 按天生成目录 ,删除,限制为图片代码,等相关配置 fs.root=data/ #fs.root=/home/dev/fs/ #fs.root=D:/fs/ #fs.domains=182=http://172.16.100.182:18080,localhost=http://localhost:8080 <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE be

yii 图片上传 图片处理

用yii自带的CUploadfile进行图片的上传,因为这个类只提供上传的功能,并没有图片的处理功能比如图片的缩减.锐化.旋转等,所以必须借助yii的扩展image来实现. 一.图片上传 数据表: CREATE TABLE `img_show` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `title` varchar(150) DEFAULT NULL, `url` varchar(100) DEFAULT NULL, `img_path`

ajax图片上传(asp.net +jquery+ashx)

一.建立Default.aspx页面 [csharp] view plain copy <%@ Page Language="C#" AutoEventWireup="true"  CodeFile="Default.aspx.cs" Inherits="_Default" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//E

spring mvc 图片上传,图片压缩、跨域解决、 按天生成文件夹 ,删除,限制为图片代码等相关配置

spring mvc 图片上传,跨域解决 按天生成文件夹 ,删除,限制为图片代码,等相关配置 fs.root=data/ #fs.root=/home/dev/fs/ #fs.root=D:/fs/ #fs.domains=182=http://172.16.100.182:18080,localhost=http://localhost:8080 <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE b

浅谈图片上传之剪切

对于一个网站来说,图片显示都是有一定的宽高比的,而客户上传的图片大多未经过剪切,故上传以后对图片进行一定的剪切是非常必要的. 如此,我们应当剪一个类来完成这项工作. public class ImageHelper{ ///图片宽高比,默认1.333 double _webWidth=1.333; /// <summary> ///网站显示图片的 宽/高比 /// </summary> public double WebWidth { get { return _webWidth;

浅谈java图片上传之剪切

对于一个网站来说,图片显示都是有一定的宽高比的,而客户上传的图片大多未经过剪切,故上传以后对图片进行一定的剪切是非常必要的. 如此,我们应当剪一个类来完成这项工作. public class ImageHelper{ ///图片宽高比,默认1.333  double _webWidth=1.333; /// <summary> ///网站显示图片的 宽/高比 /// </summary> public double WebWidth { get { return _webWidth

基于jQuery仿uploadify的HTML5图片上传控件jquery.html5uploader

(function($){ var methods = { init:function(options){ return this.each(function(){ var $this = $(this); var $clone = $this.clone(); var settings = $.extend({ id : $this.attr('id'), button:$this, uploader : '', formData:{}, auto : true, fileTypes : '*

图片上传,图片加水印,验证码制作

文件上传: 所用控件:FileUpload 使用时的思路: 1.判断用户是否选中了文件 FileUpload.FileName获取选中的文件名,判断长度,如果长度大于零就代表已经选择了文件 JS端:通过ID获取控件,然后控件的value获取选中的文件名 2.将文件保存到服务器上 FileUpload.SaveAs("绝对路径"); 3.获得绝对路径 先编写相对路径:比如"UpLoads/abc.txt" 再把路径映射成绝对路径:Server.MapPath(&quo

uedit 富文本编辑器 图片上传 图片服务器

uedit设置 修改uploader 类   源代码这个注释 $url = "upimg.com/uploadImg.php"; $tmpName = $file['name']; //上传上来的文件名 $tmpFile = $file['tmp_name']; //上传上来的临时存储路径 $tmpType = $file['type']; //上传上来的文件类型 $folder = 'goods_uedit'; //存储路径 //执行上传 $data = json_decode($t

ASP.NET图片上传(配合jquery.from.js 插件)

前端: js:        function AjaxKouBeiShopEdit() { var options = {                dataType: "json",                success: function (data) {                    alert(data);                                  },                error: function (XMLHttp