-
15 Mar 2011 10:27 AM #1Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,581
- Vote Rating
- 433
Ext.plugin.extjs.FIleDrop
Ext.plugin.extjs.FIleDrop
This is a plugin that will turn any element into an element that can accept files dropped from the desktop.
GitHub: https://github.com/mitchellsimoens/E...extjs.FileDrop
In this repo, there is an example usage. Pretty simple. If you don't specify the 'el' config on the plugin, it will default to the owning component's el.
To get file source, add listener to the owning component for the "read" event. This has two parameters, the owning component and an event. The source is under event.target.result . It may not be that easy for all files but for images this works.Mitchell Simoens @SenchaMitch
Sencha Inc, Senior Forum Manager
________________
http://www.JSONPLint.com - Source to lint your JSONP!
Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
https://github.com/mitchellsimoens
Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/
Need more help with your app? Hire Sencha Services services@sencha.com
Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is almost in print!
When posting code, please use BBCode's CODE tags.
-
15 Mar 2011 10:35 AM #2
hehe, nice.

But how do I send the file with a form?
So, I have:
The user can either select a file with the default functionality or drop it somewhere in the app.Code:<form> <input type="text" name="some_option"> <input type="file"> </form>
The examples i've found so far just talk about files, not about forms.
Thanks.
Owner of 360releases Ltd. - Sencha Touch & Ext JS consulting
twitter.com/steffenhiller
extjswithrails.com, senchatouchbits.com
-
15 Mar 2011 10:46 AM #3Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,581
- Vote Rating
- 433
Problem lies that I think there is strong security on the file input field. You can access the source of the file so you may have to use hidden fields and display it with checkboxes maybe. I will see if I can set the file input field's value but I doubt it.
Mitchell Simoens @SenchaMitch
Sencha Inc, Senior Forum Manager
________________
http://www.JSONPLint.com - Source to lint your JSONP!
Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
https://github.com/mitchellsimoens
Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/
Need more help with your app? Hire Sencha Services services@sencha.com
Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is almost in print!
When posting code, please use BBCode's CODE tags.
-
15 Mar 2011 10:48 AM #4
Yeah, you can't set the value.
Actually forget the file input field for a second. If a user drops a file, I just hide it.
But, how can I drop a file and send it together with other form variables? Ideas?
An Ajax request would be totally fine.Owner of 360releases Ltd. - Sencha Touch & Ext JS consulting
twitter.com/steffenhiller
extjswithrails.com, senchatouchbits.com
-
15 Mar 2011 11:33 AM #5Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,581
- Vote Rating
- 433
Was gonna work with CheckboxGroup but you cannot add Checkboxes in PR3. Got an error and don't have the time to dig into why.
Are you going to allow any file uploaded or just images?Mitchell Simoens @SenchaMitch
Sencha Inc, Senior Forum Manager
________________
http://www.JSONPLint.com - Source to lint your JSONP!
Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
https://github.com/mitchellsimoens
Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/
Need more help with your app? Hire Sencha Services services@sencha.com
Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is almost in print!
When posting code, please use BBCode's CODE tags.
-
15 Mar 2011 11:34 AM #6
What would the checkbox be for?
Just csv-files.Owner of 360releases Ltd. - Sencha Touch & Ext JS consulting
twitter.com/steffenhiller
extjswithrails.com, senchatouchbits.com
-
15 Mar 2011 11:39 AM #7Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,581
- Vote Rating
- 433
Mitchell Simoens @SenchaMitch
Sencha Inc, Senior Forum Manager
________________
http://www.JSONPLint.com - Source to lint your JSONP!
Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
https://github.com/mitchellsimoens
Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/
Need more help with your app? Hire Sencha Services services@sencha.com
Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is almost in print!
When posting code, please use BBCode's CODE tags.
-
15 Mar 2011 11:42 AM #8
Oh ok, well, just code is fine for me.

If you just could point me to the way I can submit an Ext JS 4 form with the dropped file, that'd be awesome.
Haven't done much with the File API yet.
Don't worry about a cool demo for now. :-POwner of 360releases Ltd. - Sencha Touch & Ext JS consulting
twitter.com/steffenhiller
extjswithrails.com, senchatouchbits.com
-
15 Mar 2011 12:11 PM #9Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,581
- Vote Rating
- 433
You can get the source of a text file by:
Tested on a TXT and JS file. The FileReader encodes the file automatically so you have to decode the string it returns.Code:var getText = function(e) { var encoded = e.target.result, result = encoded.split(","), text = atob(result[1]); return text; } new Ext.Panel({ ... listeners : { read : function(cmp, e, file) { var text = getText(e); console.log(text); //do whatever here } }, ... });Mitchell Simoens @SenchaMitch
Sencha Inc, Senior Forum Manager
________________
http://www.JSONPLint.com - Source to lint your JSONP!
Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
https://github.com/mitchellsimoens
Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/
Need more help with your app? Hire Sencha Services services@sencha.com
Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is almost in print!
When posting code, please use BBCode's CODE tags.
-
15 Mar 2011 12:14 PM #10
Sounds good!
Actually the File API is pretty awesome for my case, since the client wants a preview of the first few rows before he uploads it.
So thanks a ton!!
Owner of 360releases Ltd. - Sencha Touch & Ext JS consulting
twitter.com/steffenhiller
extjswithrails.com, senchatouchbits.com
Similar Threads
-
Highcharts adapter and plugin for ExtJS
By buz in forum Ext 3.x: User Extensions and PluginsReplies: 418Last Post: 6 May 2013, 11:19 PM -
Eclipse's Extjs plugin anybody knows one?
By andredecotia in forum Ext 3.x: Help & DiscussionReplies: 0Last Post: 15 Dec 2010, 5:40 AM -
How to create plugin for ExtJS
By martinfeng in forum Ext 3.x: User Extensions and PluginsReplies: 4Last Post: 7 Nov 2010, 9:16 AM -
rwt (a ruby on rails plugin for extjs)
By twr in forum Community DiscussionReplies: 1Last Post: 12 Feb 2009, 2:28 AM


Reply With Quote