请问一下,怎样利用 ext 上传图片到数据库
解决方案 »
- 做Flash游戏,用什么架构比较好
- 谁能给个EXTJS+JAVA做个简单的聊天程序的思路
- 怎么同事打开多个程序?
- jQuery 画面板 不会画了 请教高手指点
- {aa: '1', bb : '2'} 这叫什么?如何获取值?
- 大家过年好, 这里给大家拜个年了, 呵呵, 高手帮我看看javaScript解些xml问题, 变成关联下拉列表
- 一个有关焦点的问题,真的好奇怪,哪位大虾帮帮忙啊!!
- 简单的问题,谁能帮帮我?
- 有没有比较好的javascript编的HTML编辑器
- 请问csdn发表文章的那个比较酷的文字工具是如何实现的?(像word里面的功能)
- 关于继承,这个问题有点糊涂
- 将文件从服务器上下载到本地
fileUpload: true,//允许文件上传
frame: true,
bodyStyle: 'padding: 10px',
labelWidth: 80,
defaults: {
anchor: '95%',
allowBlank: false,
msgTarget: 'side'
},
items:
{
xtype: 'fileuploadfield',//设置上传的表单组件
id: 'form-file',
emptyText: '选择照片',
fieldLabel: '照片路径',
name: 'file1',
buttonCfg: {
text: '选择' }
}
});
var w = new Ext.Window({
width:300,
height:120,
layout:"fit",
title:"照片上传",
modal:true,
items:f,
border:false,
buttons:[{
text:"上传",
handler:function(){
f.getForm().submit({
waitTitle:"正在上传:",
waitMsg:"请稍后.....",//提交等待对话框内容
/*提交的位置*/
url:"<%=request.getContextPath()%>/CosUpLoad",
/*成功的处理*/
success:function(a,b){
eval("var ming = "+b.response.responseText);
//alert(ming.ming);
fangNa.setValue(ming.ming);
w.close();
},
failure :function(){
Ext.Msg.alert("提示","保存失败");
}//失败
});
}
},
{
text:"取消",
handler:function(){
w.close();
}
}]
})
w.show();
}
前端代码:
var UploadWin = new Ext.Window({
title: "上传图片",
layout: "fit",
width: 260,
height: 120,
minWidth: 260,
minHeight: 120,
constrain: true,
closeAction: "hide",
resizable: true,
minimizable: false,
maximizable: false,
buttonAlign: "center",
modal: true,
items: {
xtype: "form",
border: false,
labelWidth: 60,
bodyStyle: "padding:15px",
fileUpload: true,
items: {
xtype: "fileuploadfield",
fieldLabel: "文件名",
name: "file-path",
buttonText: '',
buttonCfg: {
iconCls: "upload-icon" } } },
buttons: [
{
text: "确定",
handler: function() {
if (UploadWin.get(0).getForm().isValid()) {
UploadWin.get(0).form.submit({
clientValidation: true,
url: "",
params: {
action: ""
},
success: function(form, action) {
//上传成功后的操作
},
failure: function(form, action) {
}
});
}
}
},
{
text: "取消",
handler: function() {
UploadWin.hide();
}
}
]});
你还需要有后台代码
其实数据库中最好是存图片的路径就可以了。
FileUploadField.js
这个是ext扩展的一个组件。google一下