I am using the following code to upload files ...but I am concerned about security in the sense that its available to the public and I want to be sure only certain extentions can be user...txt or .csv...they are upload address info..but if a hacker comes along...they could upload a file that take over the system..any code to protect ..ideas?
FYI..the whole site has SSL on it..if that makes a difference...
<html><head> <script language="VB" runat="server"> Sub Button1_Click(sender As Object, e As EventArgs) if FileUpLoad1.HasFile 'Uncomment this line to Save the uploaded file 'FileUpLoad1.SaveAs("C:\SomePhysicalPath" & FileUpLoad1.Filename) Label1.Text = "Received " & FileUpLoad1.FileName & " Content Type " & FileUpLoad1.PostedFile.ContentType & " Length " & FileUpLoad1.PostedFile.ContentLength else Label1.Text = "No uploaded file" end if end sub </script></head><body> <h3><font face="Verdana">File Upload</font></h3> <form runat=server> <asp:FileUpLoad id="FileUpLoad1" AlternateText="You cannot upload files" runat="server" /> <asp:Button id="Button1" Text="Upload" OnClick="Button1_Click" runat="server" /> <asp:Label id="Label1" runat="server" /> </form></body></html>
It gives you some example on determining the file size and type before uploading.
GlobaLevel
ASKER
this is good stuff..thanks...I put an instr code piece b4 the file.upload puts the file on the server to scan for extentions.....
I like the <httpRuntime> ..but I donthave that in my web.config...can I add that? even though its not in there? My users have to ave an account b4 they can upload..but im still being extra cautious...
http://msdn.microsoft.com/en-us/library/aa479405.aspx
It gives you some example on determining the file size and type before uploading.