PDA

View Full Version : Upload a file via a dialog



wycats
4 Apr 2007, 11:03 PM
Is there a Exty way to create a dialog that provides a file upload widget, and then submits the file onsubmit of the dialog?

-- Yehuda

seno
4 Apr 2007, 11:41 PM
see here:
http://www.divergingpath.com/index.cfm/2007/4/1/Ext-UploadDialog-Widget-that-extends-from-LayoutDialog

Arikon
5 Apr 2007, 12:11 AM
Seno, couldn't download full example of UploadDialog.
Check link in your blog post, please.

seno
5 Apr 2007, 4:41 AM
sorry, it's not my blog:)

aconran
5 Apr 2007, 10:48 AM
The Upload zip is fixed. I was missing a / for the uploaded zip.

I have some more additions/fixes taht I will post about later. If anyone would like the latest copy I can priv message or email it to them.

melin
5 Apr 2007, 7:22 PM
/*
* Ext - JS Library 1.0 Alpha 3 - Rev 4
* Copyright(c) 2006-2007, Jack Slocum.
*/

Ext.onReady(function(){
var chooser, btn,uploadbtn,that=this;
Ext.get("loading").remove();
var uploadbtn = Ext.get("UploadButton1");
function insertImage(data){
Ext.DomHelper.append('images', {
tag: 'img', src: data.url, style:'margin:10px;visibility:hidden;'
}, true).show(true);
btn.getEl().focus();
};

function choose(btn){
if(!chooser){
chooser = new ImageChooser({
url:'getImagesJson',
width:515,
height:400
});
}
chooser.show(btn.getEl(),insertImage);
};

btn = new Ext.Button('buttons', {
text: "Insert Image",
handler: choose
});
uploadbtn = new Ext.Button('UploadButton1', {
text: "上传",
});

var contents = Ext.get("contents");
function onUpdate(){contents.update("上传成功!");};
function onFailure(){contents.update("上传失败!");};
function upload(){
var theForm = Ext.get('contents');
var updateMgr = theForm.getUpdateManager();
updateMgr.showLoadIndicator = true;
//updateMgr.on("update",onUpdate,this);
updateMgr.on("beforeupdate",checkFile);
updateMgr.formUpdate('uploadform','upFile',true,afterUpdate.createDelegate(this));
};
function afterUpdate(el, success, response) {
uploadbtn.enable();
contents.update(response.responseText);
chooser.loaded=false;
chooser.load();
chooser.view.refresh();
console.info(response);
};

function checkFile()
{
var temp=Ext.get('FileUpload1');
//此判断不能是否有上传文件。
if(Ext.get('FileUpload1').dom.value=='')
{
Ext.MessageBox.alert('Status', ' 请选择上传文件 ');
return false;
}
else
{
uploadbtn.disable();
return true;
}
}
uploadbtn.on('click',upload,this);
});

MD
6 Apr 2007, 9:57 AM
Melin, could you post the html for yours, so we can see how that example works? Thanks.

booshan
6 Apr 2007, 10:17 AM
This is a cool Upload Dialog.

I am modifying the Grid, so that when the view link is clicked, I want to show a dialog box which retrieves the contents by XHR.

Here when I click, I am getting an error "editItem not defined". Can someone let me know, what I am doing wrong here.

Thanks



MyGridPanel = function( container, config) {
....
function renderControls( val) {
var cellVal = '<a href="#" onclick=\'editItem( ';
cellVal += val;
cellVal += ');\'><img src="images/icon_view.gif" alt="Edit" /></a>';
cellVal += '<a href="#" onclick=\'delete( "delete.do", ';
cellVal += val;
cellVal += ');\'><img src="images/cross.png" alt="Delete" /></a>';
return cellVal;
}

var cm = new Ext.grid.ColumnModel([
{
.....
},{
header: "Control",
dataIndex: 'Id',
width: 50,
sortable: false,
renderer: renderControls
}
]);

function editItem( id) {
alert(id)
}
}

mikegiddens
6 Apr 2007, 1:00 PM
I will be happy to post a demo on my www.greekhappy.com/ext section if you send me all the files.

booshan
28 Aug 2007, 3:15 PM
I have the demo running in www.qualbridge.com
You can see it under any Project->Documents.

Thanks
Booshan
www.qualbridge.com
Project Management Made Easy

jon.whitcraft
29 Aug 2007, 11:38 AM
Here is a User Extension to handle this also.

http://extjs.com/learn/Extension:UploadForm

Matt
5 Nov 2007, 9:30 AM
Does anyone still have a copy of this upload.zip? I cannot find a working link anywhere.... Thanks!

FlexIDX
5 Nov 2007, 9:48 AM
The link you provided is for a 1.X upload extension, and does not work with the 2.X code.

Chris

Matt
5 Nov 2007, 4:49 PM
Thanks for your clarification. Does anyone currently have a file upload solution in place for 2.0? I have searched the forum with no success. Any help would be more than appreciated!

priya.ranganathan
19 Nov 2007, 11:26 PM
Hi boshan,
where can i get the sample code of the file upload widget.