Extjs文件上传
2013-05-27 22:12
225 查看
head>
upload.js
viewsource
print?
upload.php
viewsource
print?
03.
<title>Uploading</title>
04.
<linkrel=
"stylesheet"
type=
"text/css"
href=
"../../resources/css/ext-all.css"
/>
05.
06.
<!--GC-->
07.
<!--LIBS-->
08.
<scripttype=
"text/javascript"
src=
"../../adapter/ext/ext-base.js"
></script>
09.
<!--ENDLIBS-->
10.
11.
<scripttype=
"text/javascript"
src=
"../../ext-all.js"
></script>
12.
13.
<scripttype=
"text/javascript"
src=
"upload.js"
></script>
14.
<linkrel=
"stylesheet"
type=
"text/css"
href=
"forms.css"
/>
15.
16.
<!--CommonStyles
for
theexamples-->
17.
<linkrel=
"stylesheet"
type=
"text/css"
href=
"../examples.css"
/>
18.
</head>
19.
<body>
20.
<scripttype=
"text/javascript"
src=
"../examples.js"
></script>
21.
<!--EXAMPLES-->
22.
<h1>Upload
with
Forms</h1>
23.
24.
<p>Thejsisnotminifiedsoitisreadable.See
25.
<ahref=
"upload.js"
>upload.js</a>.</p>
26.
<p></p>
27.
<p><ahref=
"javascript:window.location.reload();"
>reload</a></p>
28.
</body>
29.
</html>
upload.js
01.
Ext.QuickTips.init();
02.
Ext.form.Field.prototype.msgTarget=
'side'
;
03.
Ext.onReady(
function
(){
04.
var
form=
new
Ext.form.FormPanel({
05.
baseCls:
'x-plain'
,
06.
labelWidth:80,
07.
url:
'upload.php'
,
08.
fileUpload:
true
,
09.
defaultType:
'textfield'
,
10.
11.
items:[{
12.
xtype:
'textfield'
,
13.
fieldLabel:
'FileName'
,
14.
name:
'userfile'
,
15.
inputType:
'file'
,
16.
allowBlank:
false
,
17.
blankText:
'Filecan\'tnotempty.'
,
18.
anchor:
'90%'
//anchorwidthbypercentage
19.
}]
20.
});
21.
22.
var
win=
new
Ext.Window({
23.
title:
'Uploadfile'
,
24.
width:400,
25.
height:200,
26.
minWidth:300,
27.
minHeight:100,
28.
layout:
'fit'
,
29.
plain:
true
,
30.
bodyStyle:
'padding:5px;'
,
31.
buttonAlign:
'center'
,
32.
items:form,
33.
34.
buttons:[{
35.
text:
'Upload'
,
36.
handler:
function
(){
37.
if
(form.form.isValid()){
38.
Ext.MessageBox.show({
39.
title:
'Pleasewait'
,
40.
msg:
'Uploading...'
,
41.
progressText:
''
,
42.
width:300,
43.
progress:
true
,
44.
closable:
false
,
45.
animEl:
'loding'
46.
});
47.
form.getForm().submit({
48.
success:
function
(form,action){
49.
Ext.Msg.alert(
'Messagefromextjs.org.cn'
,action.result.msg);
50.
win.hide();
51.
},
52.
failure:
function
(){
53.
Ext.Msg.alert(
'Error'
,
'Fileuploadfailure.'
);
54.
}
55.
})
56.
}
57.
}
58.
},{
59.
text:
'Close'
,
60.
handler:
function
(){win.hide();}
61.
}]
62.
});
63.
win.show();
64.
});
upload.php
01.
<?php
02.
//上传文件全称
03.
$uploadfile=
"upload_files/"
.basename($_FILES[
'userfile'
][
'name'
]);
04.
05.
$message=
""
;
06.
if
(@move_uploaded_file($_FILES[
'userfile'
][
'tmp_name'
],$uploadfile)){
07.
$message=
"Filewassuccessfullyuploaded."
;
08.
}
09.
else
10.
{
11.
$message=
"Possiblefileuploadattack!"
;
12.
}
13.
14.
"{success:true,msg:'"
.$message.
"'}"
;
15.
?>
相关文章推荐
- ExtJS 多文件上传
- Extjs 文件上传
- 关于Extjs MVC模式上传文件的简单方式
- 利用jsp+Extjs实现动态显示文件上传进度
- Extjs文件上传
- springmvc +Extjs+swfUpload上传文件
- EXTJS 使用Ajax跨域上传文件
- 实用ExtJS教程100例-009:ExtJS Form无刷新文件上传
- extjs文件上传时报错 missing ) in parenthetical巧解
- Spring MVC中使用ExtJS上传文件
- EXTJS使用H5 formdata实现多文件上传
- Extjs3 + swfUpload实现多文件上传控件
- Extjs实现文件上传
- Extjs的FileUploadField文件上传出现了两个上传按钮
- Extjs+Struts实现文件文件上传问题集锦
- Extjs 使用ajax上传文件,解决Object #<HTMLDivElement> has no method 'submit'
- ExtJs4.2,文件上传,无法提交至指定URL
- ExtJs典型用法之文件上传
- ExtJS4 上传文件类型和大小的判断方法(实例) .
- c# + extjs 上传excel文件并保存到数据库