-
5 Jul 2008 5:18 PM #1
formpanel and file upload
formpanel and file upload
I'm trying to force my formpanel to upload a file together with the rest of the form data. I'm fighting with this a whole day. I searched the forum and tried lot of code. Still I get $_FILES empty on the server side... Please, help! Here is my code:
[CODE]
var zaliczki = new Ext.FormPanel({
labelAlign: 'top',
frame: false,
title: 'Zaliczki',
bodyStyle:'padding:5px',
width: 600,
items: [
{
xtype:'tabpanel',
deferredRender:false,
enableTabScroll:true,
id:'taby',
activeTab: 0,
defaults:{autoHeight:true, bodyStyle:'padding:10px', autoScroll:true},
items:[
{
title:'Transza 1',
layout:'form',
defaultType: 'textfield',
items: [
{
xtype:'tabpanel',
deferredRender:false,
enableTabScroll:true,
id:'taby2',
activeTab: 0,
defaults:{autoHeight:true, bodyStyle:'padding:10px', autoScroll:true},
items:[
{
title:'Zaliczka',
layout:'form',
defaultType: 'textfield',
items: [
{
fieldLabel: 'Kwota zaliczki (w PLN)',
name: 'data[{{$smarty.section.dane.index}}][zal_kwota]',
value: '{{$dane[dane].zal_kwota}}'
},
{
fieldLabel: 'Procent w stosunku do kwoty wsp
-
5 Jul 2008 9:59 PM #2
You need to tell the form that it is to upload a file.
include isUpload: true in the form config object.Search the forum: http://www.google.com/coop/cse?cx=01...%3Az7of1ufqccu
Read the docs too: http://extjs.com/deploy/dev/docs/
Scope: http://extjs.com/forum/showthread.ph...642#post257642
-
6 Jul 2008 2:34 AM #3
Thanks Animal! You are great! Now it works! Complete code below.
But I have one additional question: now I cannot see the request in Firebug. Why?
[CODE]
var zaliczki = new Ext.form.FormPanel({
labelAlign: 'top',
frame: false,
title: 'Zaliczki',
bodyStyle:'padding:5px',
width: 600,
fileUpload:true,
isUpload: true,
method:'POST',
enctype:'multipart/form-data',
items: [
{
xtype:'tabpanel',
deferredRender:false,
enableTabScroll:true,
id:'taby',
activeTab: 0,
defaults:{autoHeight:true, bodyStyle:'padding:10px', autoScroll:true},
items:[
{
title:'Transza 1',
layout:'form',
defaultType: 'textfield',
items: [
{
xtype:'tabpanel',
deferredRender:false,
enableTabScroll:true,
id:'taby2',
activeTab: 0,
defaults:{autoHeight:true, bodyStyle:'padding:10px', autoScroll:true},
items:[
{
title:'Zaliczka',
layout:'form',
defaultType: 'textfield',
items: [
{
fieldLabel: 'Kwota zaliczki (w PLN)',
name: 'data[{{$smarty.section.dane.index}}][zal_kwota]',
value: '{{$dane[dane].zal_kwota}}'
},
{
fieldLabel: 'Procent w stosunku do kwoty wsp
-
6 Jul 2008 2:39 AM #4
File uploading is processed through a hidden iframe. I had no experience with uploading files, but I suspect the request is not shown in firebug because it only shows requests associated with current frame (that is, your page)
-
6 Jul 2008 9:34 AM #5
Yeah, sounds reasonably...
Animal, what is your opinion?
-
6 Jul 2008 9:38 AM #6
That's right. files can only be uploaded by real form submits. An iframe is used. You will not be able to see the submit body in Firebug because it is a mime multipart message.
If you want to check it out, you'll have to use Fiddler.Search the forum: http://www.google.com/coop/cse?cx=01...%3Az7of1ufqccu
Read the docs too: http://extjs.com/deploy/dev/docs/
Scope: http://extjs.com/forum/showthread.ph...642#post257642
-
6 Jul 2008 10:41 AM #7
-
6 Jul 2008 11:48 PM #8
Yep.
Search the forum: http://www.google.com/coop/cse?cx=01...%3Az7of1ufqccu
Read the docs too: http://extjs.com/deploy/dev/docs/
Scope: http://extjs.com/forum/showthread.ph...642#post257642
-
7 Jul 2008 7:45 AM #9
Looks interesting... I will give it a try.
Thanks a lot for your help!
-
11 Jul 2008 5:27 AM #10aaaee2Guest
As well as the author of this thread I has lead to solve all the day simple (only not in ExtJS) task: I wish to upload a file! I have tried a lot of code, patches for source/data/Connection.js, have re-read all that have found on the given subject. Please, help me.
FF-3.0, Ext-2.1.0 (rev 2042).
A code fragment:Result:Code:var form = new Ext.form.FormPanel({ baseCls:'x-plain', layout:'absolute', url:'import_foo.php', fileUpload:true, isUpload:true, method:'POST', enctype:'multipart/form-data', items: [{ x: 0, y: 3, xtype: 'label', text: 'Foo file:' },{ x: 105, y: 0, name: 'foofile', xtype: 'textfield', inputType: 'file' }] }); if (!win) { win = desktop.createWindow({ id: 'foobar-win' + barId, title: barName + ' - foobar', width: 400, height: 116, iconCls: 'import', resizable: false, maximizable: false, minimizable: false, layout: 'fit', plain: true, bodyStyle: 'padding:10px;', buttonAlign: 'center', modal: true, items: form, buttons: [ {text: 'Import Foo', handler: function() { form.getForm().submit(); } }, {text: 'Cancel', handler: function() { win.close(); } } ] }); } win.show();This error only when "fileUpload:true", otherwise no errors, but $_FILES array in PHP side is still empty.Code:Syntax error: [foofile] => Array\n ext-all-debug.js (line 6681)


Reply With Quote