Hi,
I have uploaded 3 files using file upload with Specific User Id (Meaning User can have 3 image files or less than 3) in one folder
Now I want to download all 3 files at once by User Id (on page load or on button click event )
Is it possible ?
Thank You
Sushant TorankarPosted Jul 17, 2023, 3:16 PM
I am trying like :
string file1 = filepath + filename
string file2 = filepath + filename
string file3 = filepath + filename
DownloadFile(file1);
DownloadFile(file2);
DownloadFile(file3);
Using same Code in DownloadFile, only file name is different.
But After downloading file1 and on downloading file2, I am getting "Server cannot clear headers after HTTP headers have been sent" error
DownloadFIle code is :
Response.Clear(); Response.ClearHeaders(); Response.Buffer = true; Response.BufferOutput = true;
Response.AddHeaders("COntent-Disposition", string.Format("attachment; filename = {0}{1}", FileName, type));
Response.Charset = ""; Response.ContentType = "application/pdf"; Response.TransmitFIle(url); Response.Flush();
Praveen MishraPosted Jul 13, 2023, 8:38 AM
Hi Sushant ,
You can easily download multiple files on pae load , here is the example code.
Another Redirected Page Code of Page Load Are :
Jignesh KumarPosted Jul 13, 2023, 4:25 AM
Hello Sushant,
Please use this one which will help you out to download all files from specific folder,
Anoop Kumar SharmaPosted Jul 13, 2023, 3:07 AM
Hi Sushant,
The best way is to zip all the multiple files and download the .zip file at the user end.
https://www.aspsnippets.com/Articles/Zip-a-Folder-Directory-and-Download-in-ASPNet-using-C-and-VBNet.aspx
Hope this will help you.
Mudzakkir TohaPosted Jul 13, 2023, 1:51 AM
of course that is possible to do.
match your file using userId, or you can save file location to db with key userId. and then read the files using foreach.