Click here to Skip to main content
15,901,205 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I want to make upload of software from admin side of any extension and give access to only normal user from admin side by providing normal user separate userid and password for downloading the software.Any idea please help.

for upload i have used this
C#
string filename = Path.GetFileName(fileUpload1.PostedFile.FileName);
fileUpload1.SaveAs(Server.MapPath("Files/"+filename));
conn.Open();
SqlCommand cmd = new SqlCommand("insert into upload(FileName,FilePath) values(@Name,@Path)",conn);
cmd.Parameters.AddWithValue("@Name",filename );
cmd.Parameters.AddWithValue("@Path", "Files/"+filename );
cmd.ExecuteNonQuery();
conn.Close();
BindGridviewData();
</pre>

for download used this
C#
LinkButton lnkbtn = sender as LinkButton;
GridViewRow gvrow = lnkbtn.NamingContainer as GridViewRow;
string filePath = gvDetails.DataKeys[gvrow.RowIndex].Value.ToString();
Response.ContentType = "";
Response.AddHeader("Content-Disposition", "attachment;filename=\"" + filePath + "\"");
Response.TransmitFile(Server.MapPath(filePath));
Response.End();
</pre>

but it is not supporting video file and do you have idea whether how to give access for normal user from admin user to download software.By defining Roles may it solve the problem
Posted
Updated 4-Jul-13 20:17pm
v2

1 solution

If you want to enable user downloading any file type, you can use application/octet-stream as your ContentType
C#
Response.ContentType = "application/octet-stream";
 
Share this answer
 
Comments
aatish442000 5-Jul-13 3:07am    
thanks but it upload only minimum sized software in kb.But when i started to upload software of size 25 mb then nothing happens only message the connection has reset anu idea
thanh_bkhn 5-Jul-13 3:13am    
In IIS you could set the maximum upload file size in the web.config file
<configuration>
<system.web>
<httpRuntime maxRequestLength="100000000" />
</system.web>
</configuration>
thanh_bkhn 5-Jul-13 3:14am    
For more information about httpRuntime config, take a look at
http://msdn.microsoft.com/en-us/library/e1f13641(VS.80).aspx
aatish442000 5-Jul-13 3:21am    
thanks but it is not working same thing happens like connection was reset
thanh_bkhn 5-Jul-13 3:31am    
Is you testing in your local PC? Then if you try to upload a small file, is it uploaded completely? Then when uploading a large file, what is exactly the error message?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900