We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

In my grid, how can I add a column that is of type input file?

Hello, I would like to know how I can add a column that allows uploading multimedia files and how to save the file in a specific path, and store said path in the database.

The  following image is how my grid is currently, to add a column of media content.


The following image is an example of the button to add.




The columns grid is declared as follows:





3 Replies

RS Rajapandiyan Settu Syncfusion Team January 11, 2023 04:30 PM UTC

Hi Santy,


Thanks for your update.


You can try to implement the EJ2 Uploader in the Grid component from your side. Please let us know if you face any difficulties while achieving it.


If you want to show the file uploader on each row, you achieve it throw columnTemplate feature of Grid,


columnTemplate: https://ej2.syncfusion.com/documentation/grid/columns/column-template/


Sample Demos: https://ej2.syncfusion.com/demos/#/material/grid/column-template.html


Uploader component documentation: https://ej2.syncfusion.com/documentation/uploader/getting-started/


Also, Refer to the below documentation for more information,


Implement file Uploader on Editing a Grid row: https://www.syncfusion.com/kb/12693/how-to-edit-the-column-in-grid-using-the-uploader-control


Regards,

Rajapandiyan S



SA Santy replied to Rajapandiyan Settu January 20, 2023 04:56 PM UTC

Thank you very much for your answer, it helped me a lot.


Now I have a question, how can I get the directory of my file once I select it?


Next, I show the code on which I am basing myself. I understand that in these variables, there is the metadata of the media file that I select, but I can't locate the path (on my computer) where it was in the file when it was selected.

var file = args.file.rawFile;

var reader = new FileReader();




RR Rajapandi Ravi Syncfusion Team January 24, 2023 03:54 AM UTC

Santy,


You cannot get the selected file path in both client side and server side due to security reasons. Refer to the following common links for more information. 


https://forums.asp.net/t/1917545.aspx?how+to+get+the+full+path+of+the+file+name+that+is+selected+using+fileupload+control


https://stackoverflow.com/questions/53759070/how-to-get-path-directory-from-filereader


Loader.
Up arrow icon