Note that there are some explanatory texts on larger screens.

plurals
  1. POExtjs 4 upload success function does not react
    text
    copied!<p>i have a grid with an toolbar and on that toolbar an upload option is added, so the upload is alright and it works , but after the file was uploaded to the server the success function does not react.</p> <p>here my upload code:</p> <pre><code>upload: function () { Ext.create('Ext.window.Window', { title: 'Upload', width: 300, layout: 'fit', draggable: false, resizable: false, modal: true, bodyPadding: 5, items: [{ xtype: 'form', bodyPadding: 10, frame: true, items: [{ xtype:'filefield', name:'file', fieldLabel: 'File', buttonText: 'Select File', labelWidth: 30, anchor: '100%' }, { xtype: 'button', text: 'Upload', handler: function(){ var form = this.up('form').getForm(); if(form.isValid()){ form.submit({ method: 'POST', url: 'http://localhost:3000/upload', success: function (form, action) { Ext.Msg.alert('Success', 'Your File has been uploaded.'); console.log(action); }, failure : function (form,action) { Ext.Msg.alert('Error', 'Failed to upload file.'); } }) } } }] }], }).show(); }, }); </code></pre> <p>and the server response :</p> <pre><code>app.post('/upload', function(req, res) { res.header('Access-Control-Allow-Origin', '*'); res.header('Content-Type','application/json; charset=UTF8'); var tmp_path = req.files.file.path; var newPath = __dirname + '/files/' + req.files.file.name; fs.rename(tmp_path, newPath, function (err){ if (err) throw err; }); var path = newPath; var name = req.files.file.name; connection.query('SELECT name FROM audio WHERE name = ?', [name] , function(err,result) { if (result[0]) { console.log('File already exist'); res.status(400).send(JSON.stringify()); } else { connection.query('INSERT INTO audio (name, path) VALUES (?,?)', [name,path], function (err,result) { if (err) throw err; var test = { success: true }; res.send({success:true}); console.log('success'); }); } }); }); </code></pre> <p>i can provide more code if necessary, thanks in advance</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload