0

I am trying to make a file uploader using html tags. This is my html for the file uploader:

<tr>
 <td class="label" style="width:15%">
  Upload File
 </td>
 <td class="description" >
  <input type="file" id="FileUpload1" class="largeTextField" multiple="multiple"   
  style="width:260px;"/>
  <input type="button" id="btnUpload" value="Upload"  onclick="UploadFile()" />
 </td>
 <div class="validator" id="txtUploadFileVld" style="display: none">*</div>
</tr>

Below is my table in database:

CREATE TABLE [dbo].[tblFiles](  
    [id] [int] IDENTITY(1,1) NOT NULL,  
    [Name] [varchar](50) NOT NULL,  
    [ContentType] [nvarchar](200) NOT NULL,  
    [Data] [varbinary](max) NOT NULL  
    ON [PRIMARY] TEXTIMAGE_ON [PRIMARY])

Now on onclick I have a function of UploadFile(). How do I code such that it access the filename and content type of the file. and also reads the file so I can save in it in the database.

Prashanth Reddy
  • 749
  • 5
  • 19
Unknown
  • 145
  • 2
  • 11

2 Answers2

0

https://stackoverflow.com/a/27523255/10967697 This could help you. As much i have understood your problem, the solution for that is you have to view the file first by using this above link and then save the file in the database by using the UploadFile().

Engineer S. Saad
  • 378
  • 4
  • 19
0

To understand the problem better you could tell the actual requirement,your approach to solve and the problem faced.

This might help getting better suggestion and ideas from the forum members.

Please post the full relevant code including the javascript part.

If you need suggestion for writing the Javascript part of uploading the File here is a tutorial that might help.

How to upload a file in ASP.NET MVC

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Mohan
  • 81
  • 4