G
Guest
I'm uploading files to a location on my server. It works fine accept, I can't
seem to get the control over the max file size to upload and the types I want
to only allow.
Max file size = 50KB
Types = .gif and .jpg
I've tried using the accept property but it doesn't work, the dialog opens
asking for *.* all files and allows them to be uploaded. And I can't restrict
file size?
Is there a way to set this in the code-behind routine via the HtmlInputFile
properties?
i.e.
<input id="inpFileUp" Type="file" Accept="image/gif" runat="server" />
I'm using the MS routine that works pretty well, found on their article:
Protected WithEvents inpFileUp As HtmlInputFile
If Not inpFileUp.PostedFile Is Nothing And
inpFileUp.PostedFile.ContentLength > 0 Then
Dim fn As String =
System.IO.Path.GetFileName(inpFileUp.PostedFile.FileName)
Dim SaveLocation As String
SaveLocation = Server.MapPath("\xxxx\xxxxxxx\" & fn)
Try
inpFileUp.PostedFile.SaveAs(SaveLocation)
Response.Write("The file has been uploaded.")
Catch Exc As Exception
Response.Write("Error: " & Exc.Message)
End Try
Else
Response.Write("Please select a file to upload.")
End If
Thanx a bunch.
seem to get the control over the max file size to upload and the types I want
to only allow.
Max file size = 50KB
Types = .gif and .jpg
I've tried using the accept property but it doesn't work, the dialog opens
asking for *.* all files and allows them to be uploaded. And I can't restrict
file size?
Is there a way to set this in the code-behind routine via the HtmlInputFile
properties?
i.e.
<input id="inpFileUp" Type="file" Accept="image/gif" runat="server" />
I'm using the MS routine that works pretty well, found on their article:
Protected WithEvents inpFileUp As HtmlInputFile
If Not inpFileUp.PostedFile Is Nothing And
inpFileUp.PostedFile.ContentLength > 0 Then
Dim fn As String =
System.IO.Path.GetFileName(inpFileUp.PostedFile.FileName)
Dim SaveLocation As String
SaveLocation = Server.MapPath("\xxxx\xxxxxxx\" & fn)
Try
inpFileUp.PostedFile.SaveAs(SaveLocation)
Response.Write("The file has been uploaded.")
Catch Exc As Exception
Response.Write("Error: " & Exc.Message)
End Try
Else
Response.Write("Please select a file to upload.")
End If
Thanx a bunch.