In the following link http://www.ajaxuploader.com/Demo/Ajax-based-File-storage.aspx., file is saved in some location and downloading the from the location ,based on the path and file name saved in DB.
But for me just iam saving the file size and file name in db. Project already in production. if change the code based on the url what u send, then it will problem, b'cas we are not saving the file locally or any where else. Just saving the file size which returns the bytest of array.
so image will be saved in db as bytes of array.
i. e Response.OutputStream.Write( DocumentFile, 0, DocumentFile.Length); in this line DocumentFile is file size of upload file which type is bytes of array, but the ajaxuploader returns the int. so at time of downloading the file, the file can not viewed.
Use the below control, upload and save the filename and filesize in db , fetching the same details from the db for the downloading using the below code. try it.
<
asp:FileUpload ID="FileUpload1" CssClass="ListBox" runat="server" Width="250px" />
1. using
CuteWebUI:UploadAttachments :- iam saving the filesize and filename and other details in db.
for the downloading the files, the filesize and filename will be fetched from db and below code is used for downloading.
When i download file, it is not opening , telling that no preview is available.
Below is the code:-
Page.Response.Clear();
Response.ClearContent();
Response.ClearHeaders();
switch
(FileType.ToUpper())
{
case "XLS": Response.ContentType = "application/ms-excel"; break;
case "XLSX": Response.ContentType = "application/ms-excel"; break;
case "DOC": Response.ContentType = "application/msword"; break;
case "DOCX": Response.ContentType = "application/msword"; break;
case "PDF": Response.ContentType = "application/ms-excel"; break;
case "HTML": Response.ContentType = "application/octet-stream"; break;
case "XML": Response.ContentType = "application/octet-stream"; break;
case "XSN": Response.ContentType = "application/msinfopath"; break;
default: Response.ContentType = "application/octet-stream"; break;
}
Response.AddHeader(
"Content-Disposition", "attachment;filename=" + FileName + "");
Response.OutputStream.Write( DocumentFile, 0, DocumentFile.Length);
Response.BinaryWrite(DocumentFile);
Response.Flush();
Response.Close();
Problem is in DocumentFile size .
Same code is working fine for asp.net file upload control. I have already mentioned in chat about this issue..
Can you provide me solution.