Hi,
Thanks for the reply.You have written the code in codebehind of aspx.
Instead I should write in jquery.
My requirement is to write the code in jquery and send to REST because we use only html files and not aspx.
I am using html ,jquery and rest in .net.
If I use <asp:FileUpload ID="flup" runat="server" /> control I can get flup.FileContent and upload images.
But the requirement is I am using <input type="file" runat="server" id="fileup" />.
I want to send the filename and filecontent as parameter from jquery to the REST FileUpload method which is written in .net
protected void btnSubmit_Click(object sender, EventArgs e)
{
FileUpload(flup.FileName, flup.FileContent);
}
private void FileUpload(string fileName, Stream fileStream)
{
FileStream fileToupload = new FileStream("D:\\FileUpload\\" + fileName, FileMode.Create);
byte[] bytearray = new byte[10000];
int bytesRead, totalBytesRead = 0;
do
{
bytesRead = fileStream.Read(bytearray, 0, bytearray.Length);
totalBytesRead += bytesRead;
} while (bytesRead > 0);
fileToupload.Write(bytearray, 0, bytearray.Length);
fileToupload.Close();
fileToupload.Dispose();
}
Shanpricol, if this helps please login to Mark As Answer. | Alert Moderator