Hello
I have the following script to upload files:
It seems to work OK. I also aim to limit the size of files that can be uploaded and use this Web1.config file (so I have two Web.config files: the other one has my database connection details in it):
Is my upload.aspx or upload.aspx.vb file able to 'see' this Web.config file because I haven't referenced it in either of those two aspx files?
I wonder also if it may be worth notifying the user if he tries to go over the file size limit, but I am not sure how to do that.
Many thanks!
I have the following script to upload files:
Code:
Protected Sub btnUpload_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnUpload.Click
If FileUpload1.HasFile Then
Try
FileUpload1.SaveAs("C:\Uploads\" & _
FileUpload1.FileName)
Label1.Text = "File name: " & _
FileUpload1.PostedFile.FileName & "<br>" & _
"File Size: " & _
FileUpload1.PostedFile.ContentLength & "<br>" & _
"Content type: " & _
FileUpload1.PostedFile.ContentType & "<br>" & _
"Location Saved: C:\Uploads\" & _
FileUpload1.FileName
Catch ex As Exception
Label1.Text = "ERROR: " & ex.Message.ToString()
End Try
Else : Label1.Text = "You have not specified a file."
End If
Label1.Attributes.Add("style", "display:block")
End Sub
It seems to work OK. I also aim to limit the size of files that can be uploaded and use this Web1.config file (so I have two Web.config files: the other one has my database connection details in it):
Code:
<?xml version="1.0"?>
<configuration>
<system.web>
<compilation debug="false" targetFramework="4.5" />
<httpRuntime targetFramework="4.5" />
</system.web>
<authentication mode="Forms">
<authorization>
<deny users="?" />
<allow users="*" />
</authorization>
<forms loginUrl="upload.aspx"
protection="All"
timeout="30"
name="AppNameCookie"
path="/FormsAuth"
requireSSL="false"
slidingExpiration="true"
defaultUrl="index.aspx"
cookieless="UseCookies"
enableCrossAppRedirects="false"/>
</authentication>
<!--Limit file size to 500KB-->
<system.web>
<httpRuntime maxRequestLength="524288"/>
</system.web>
</configuration>
Is my upload.aspx or upload.aspx.vb file able to 'see' this Web.config file because I haven't referenced it in either of those two aspx files?
I wonder also if it may be worth notifying the user if he tries to go over the file size limit, but I am not sure how to do that.
Many thanks!