Hi is there any way to restrict fileupload control like upload only images or some thing like pdfs and one more imp thing is I would like to browse file from only specific directory only (like C:\Images). Is there any way to restrict like this?
If (Not graphicupload.PostedFile
Is Nothing)
And (graphicupload.PostedFile.ContentLength > 0)
Then
Dim graphicPath
As String = graphicupload.PostedFile.FileName
Dim extension
As String = Path.GetExtension(graphicPath)
If extension =
".jpg" Or extension =
".gif" Then
Then upload the file here....
There is also another way to check the file type, like if it's of type image. Don't have that sample with me right now.
I think it would be something like graphicupload.type
As for controling what directory the user goes to with the input file control, can't do that.
But, you can check the path they chose.
And 2.0 has thier own control now - haven't needed to use it yet:
Hi thank you for your reply but I want to restrict one folder to browse. i.e. when i click browse button i should search (or upload) files from onle one specific directory or folder only (like if I press browse button i should get files from C:\myImages
folder only). Is there any way to do like this?
nagsline
Member
104 Points
153 Posts
Restrict Fileupload
Nov 27, 2006 03:16 PM|LINK
Hi is there any way to restrict fileupload control like upload only images or some thing like pdfs and one more imp thing is I would like to browse file from only specific directory only (like C:\Images). Is there any way to restrict like this?
Thank you
Jai
Zath
Star
8057 Points
1772 Posts
Re: Restrict Fileupload
Nov 27, 2006 05:02 PM|LINK
Using input file control named graphicupload
If (Not graphicupload.PostedFile Is Nothing) And (graphicupload.PostedFile.ContentLength > 0) Then
Dim graphicPath As String = graphicupload.PostedFile.FileName Dim extension As String = Path.GetExtension(graphicPath) If extension = ".jpg" Or extension = ".gif" ThenThen upload the file here....
There is also another way to check the file type, like if it's of type image. Don't have that sample with me right now.
I think it would be something like graphicupload.type
As for controling what directory the user goes to with the input file control, can't do that.
But, you can check the path they chose.
And 2.0 has thier own control now - haven't needed to use it yet:
http://www.c-sharpcorner.com/UploadFile/mahesh/FileUpload10092005172118PM/FileUpload.aspx?ArticleID=79850d6d-0e91-4d7b-9e27-a64a09b0ee6b
Zath
nagsline
Member
104 Points
153 Posts
Re: Restrict Fileupload
Nov 28, 2006 01:24 AM|LINK
Hi Zath thanx for your reply, but I'm not having any idea about VB please provide me example in c#.net
Thank you
Jai
jessjing
Contributor
4392 Points
872 Posts
Re: Restrict Fileupload
Nov 28, 2006 02:56 AM|LINK
hi,
here is a sample code for you to refer to
http://www.codeproject.com/aspnet/netimageupload.asp
hope it helps
nagsline
Member
104 Points
153 Posts
Re: Restrict Fileupload
Nov 28, 2006 04:13 AM|LINK
Hi thank you for your reply but I want to restrict one folder to browse. i.e. when i click browse button i should search (or upload) files from onle one specific directory or folder only (like if I press browse button i should get files from C:\myImages folder only). Is there any way to do like this?
Thank you
jessjing
Contributor
4392 Points
872 Posts
Re: Restrict Fileupload
Nov 28, 2006 05:14 AM|LINK
hi,
it may be hard to implement it using FileUpload control, perhaps, you should find some third-part control
http://file-upload.qarchive.org/
thx