fileuloadfield, upload file to store without server side

  1. #1

    fileuloadfield, upload file to store without server side

    Hi, friends!

    I have a form where one of fields is FileUploadField and GridPanel with records.

    The task is to use the file uploading field to upload a file to the record in store using only javascript, without upload to server side. After multiple changes (uploads any files to store records), the modified records will be sent to server side, where files will be recorded to database table on blob formats.

    In my opinion, the file may be converting to base64 format and stored in grid store. How can i do this? I navnt any workable examples.

    May be you have any variations to resolve my task?

    @fabricio.murta pls help

    Tnx.
  2. #2
    Hello @e1ement, and welcome to Ext.NET forums!

    I am afraid we don't have any cooked example on the exact task you want, and not that native feature from Ext.NET or its underlying framework (Ext JS).

    Yet, I believe you can easily accomplish this task with the FileUploadField component. You can either bind a "send to grid" button to serve as a "upload" button (to assign the file to the grid), or bind the field's change event.

    Then just access the field's internal input type=file HTML element and extract the file contents and add the file to the grid. MDN has good documentation on the file input element (and File API) you should understand in order to attain your objective.

    The "supported" way to get the internal file input field from the Ext.NET component would be the extractFileInput() method. The drawback of this approach would be the input field is reset once you call this method (as for emulating a file upload success -- which may just be the desired behavior in your case).

    If you just want to hit the file data while not touching the field, you can get the internal file input field (beware, dragons ahead!) via the undocumented, unsupported (may break at any time between upgrades without any warning) fileInputEl.dom reference.

    As an example of getting the field from actual code, in the example Form > FileUploadField > Basic, you can get the input field via either:

    App.BasicField.fileInputEl.dom (unsupported)

    App.BasicField.extractFileInput() (supported, resets the field on call)

    Now, as far converting the file contents, it is beyond the scope of Ext.NET. The documentation provided above should help you with that (MDN docs).

    You can probably store the file as-is (binary and all) in a field as long as you don't specify an explicit type for the store's model field. Which would imply no conversion is made. You shouldn't though try to show this field contents in a grid cell though. To submit the grid, you may need to ensure it is stringified. I believe it would be.

    Well, hope this helps!
    Fabrício Murta
    Developer & Support Expert
  3. #3
    @fabricio.murta

    it's working, thx

    i stored encoded file in store record
  4. #4
    Glad it helped, thanks for the feedback!
    Fabrício Murta
    Developer & Support Expert

Similar Threads

  1. [CLOSED] multiple file upload and file size at client side
    By mirwais in forum 1.x Premium Help
    Replies: 24
    Last Post: Dec 15, 2014, 6:44 AM
  2. [CLOSED] Get uploaded file name and file path server side.
    By speedstepmem4 in forum 2.x Premium Help
    Replies: 9
    Last Post: Jul 31, 2014, 12:24 PM
  3. [CLOSED] File Upload does not work at IIS Server
    By jesperhp in forum 1.x Premium Help
    Replies: 6
    Last Post: Jul 17, 2013, 7:35 AM
  4. [CLOSED] Multiple file support to upload in file upload control
    By legaldiscovery in forum 1.x Premium Help
    Replies: 1
    Last Post: Feb 01, 2013, 10:41 AM
  5. Replies: 2
    Last Post: Jan 17, 2012, 9:58 AM

Tags for this Thread

Posting Permissions