View Full Version : File Upload in Database

14 Apr 2014, 10:44 PM
I am using Ext.form.field.File to choose a file from the user.
It can be image / excel / document files.

I need to know how to upload the selected file into Database?
Please provide some samples / code snippet

15 Apr 2014, 1:23 PM
Once you upload the file to the sever, the server code has to open the table and insert the file into blob field.
What is your server language?

Something like this:

16 Apr 2014, 9:51 AM
How to handle the file upload if server language is C#?
We have WCF web service using C#, where we need to get the file object and handle insertion into database.

Trying to use below piece of code:

url: '/FileUploadTest/Service1.svc/UploadFile',
waitMsg: 'Uploading your photo...',
success: function (fp, o) {
msg('Success', 'Processed file on the server');
failure: function (form, action) {
Ext.Msg.alert('Failed', action.result ? action.result.message : 'No response');

Server side code is:

public string UploadFile(HttpPostedFileWrapper file, int id)
//my DB insertion code goes here;

But get error
500 System.ServiceModel.ServiceActivationException

If I change the input type in server from HttpPostedFileWrapper to Byte[],
I get below error:
Resource interpreted as Document but transferred with MIME type

As mentioned, we need to be able to upload any type of file.

We will also need to understand how to download the saved file from database.

Below is our sample screen:

On click of upload button file should be saved in database.

We need to show the button/link in "Document" column of the grid and download the file on click of that button/link.

Any help is greatly appreciated...

Mahi :)

20 Apr 2014, 10:27 PM
Is this not possible in Sencha? :-?

If not what would be the work-around? /:)

Can we include it as a part of iFrame and load asp.net web app as the src to the iFrame?

If so, I would like to know how to handle iFrame in Sencha.:-/