ExtJS Version : 4.1.0
Answered – See my response below… quite silly really
I have a simple form with a few fields, one of them being of the xtype fileuploadfield. I listen for the click event on my form’s save button in the Controller’s this.control method. When the click event occurs, I run a method saveForm, which looks like this:
saveForm: function(button) {
/** Get the Window Object and retrieve the Form*/
var currentWin = button.up('window'),
form = currentWin.down('form');
/** Get the Form Object */
form = form.getForm();
/** ...continued... */
}
At this point in my method, I can console.log the form object, inspect the object’s _fields and see my fileuploadfield and the path of the file I input in the field (i.e. C:\fakepath\somefile.png). I can also perform form.getField('upload-field-id'); to get the upload field element. The method form.hasUpload() returns TRUE.
The kicker is that when I call form.submit() and var_dump() the $_FILES array on my server, it is empty!
In the examples that I’ve seen of file uploading in ExtJS, the form submission happens via a handler function on the Save button in the view. As I like to keep logic for handling button presses in my controller, I’m hoping this is not my only option!
Any input would be greatly appreciated, thank you for your time.
I feel a bit silly, but the problem was pertaining to retrieving the form object from the button passed to my
saveFormmethod.Corrected:
In my ExtJS controller…
In my back-end (Zend), my controller action is simply:
As expected, my Chrome Inspector outputs the following upon clicking the save button:
The server has successfully received the file upload!