vb.net - About Uploading multiple files and giving the filename to fileupload control...
-
Upload
amelia-renata -
Category
Documents
-
view
213 -
download
0
Transcript of vb.net - About Uploading multiple files and giving the filename to fileupload control...
-
7/28/2019 vb.net - About Uploading multiple files and giving the filename to fileupload control programatically in asp.pdf
1/3
6/20/13 vb.net - About Uploading multiple files and giving the filename to fileupload control programatically in asp.net - Stack Overflow
stackover flow.com/questions/16503823/about-uploading-mul tiple- fi les-and-giving-the- fi lename-to- fi leupload-control -pro 1/3
Tell me more
My client has one requirement.
He wants to upload all the text files from folder "D:/MyFolder/" by clicking on a button.
So I tried It but I am having the problems.
Here is the code:
ProtectedSub btnAutoUpload_Click(ByVal sender AsObject,ByVal e As System.Even
Dim dbProvider AsString Dim dbSource AsString
Dim con AsNew OleDbConnection
Dim SQL AsString
Dim da As OleDbDataAdapter
Dim ds AsNew DataSet
'Connecting and retrieving data form Database.
dbProvider ="PROVIDER = Microsoft.Ace.OLEDB.12.0;"
dbSource ="Data Source = '"& Server.MapPath("~/App_Data/Data.accdb")&"'"
con.ConnectionString = dbProvider & dbSource
SQL ="SELECT * FROM tblUserDetails WHERE UserType = 'Company'"
da =New OleDbDataAdapter(SQL, con)ds.Clear()
da.Fill(ds,"tblUserDetails")
Dim fileUploadPath AsString="C:/MUNIM/"
Dim NumberOfFilesToUpload AsInteger= FileCount(fileUploadPath)
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, noregistration required.
bout Uploading multiple files and giving the filename to fileupload controlprogramatically in asp.net
http://engine.adzerk.net/r?e=eyJhdiI6NDE0LCJhdCI6NCwiY20iOjg0NywiY2giOjExNzgsImNyIjo1MDk0LCJkaSI6IjA2YTQ2NTA5M2VhNjQ1MjhhMmRjZjI0ODI4N2VjMGZjIiwiZG0iOjEsImZjIjoxMDEzOSwiZmwiOjI0NDQsImt3IjoiYXNwLm5ldCx2Yi5uZXQsZmlsZS11cGxvYWQiLCJudyI6MjIsInJmIjoiaHR0cHM6Ly93d3cuZ29vZ2xlLmNvbS8iLCJydiI6MCwicHIiOjE1NjgsInN0Ijo4Mjc3LCJ6biI6NDMsInVyIjoiaHR0cDovL2NhcmVlcnMuc3RhY2tvdmVyZmxvdy5jb20vP2JtaWQ9QzIwQjEgIn0&s=7nH_eMGESX_kWrVSvCadimuxZnMhttp://stackoverflow.com/questions/16503823/about-uploading-multiple-files-and-giving-the-filename-to-fileupload-control-prohttp://stackoverflow.com/abouthttp://stackoverflow.com/ -
7/28/2019 vb.net - About Uploading multiple files and giving the filename to fileupload control programatically in asp.pdf
2/3
6/20/13 vb.net - About Uploading multiple files and giving the filename to fileupload control programatically in asp.net - Stack Overflow
stackover flow.com/questions/16503823/about-uploading-mul tiple- fi les-and-giving-the- fi lename-to- fi leupload-control -pro 2/3
ishal
31 1 9
1 Answer
Chris Buckler
987 1 4 20
Dim Extension AsString
Dim fileName AsString
Dim files()AsString
files = IO.Directory.GetFiles(fileUploadPath)
For x AsInteger=0To NumberOfFilesToUpload -1
How is this possible?
Should I use FileUpload Control?
If yes, then How can I select specific folder to upload files from?
Or How should I give Filename to FileUpload Control Programatically? as it is readonly.
asp.net vb.net file-upload
asked May 12 at 3:09
You cant really have your server just grab files off a clients machine legitimately. This is what the fileupload control is for. Generally the client initiates the upload.
You can use file upload control with multiple attribute to allow you to select multiple files in IE version 10+
, FF, Chrome, Opera. Otherwise, without the multiple attribute it is tedious to upload files since you can't
shift / control click all files.
You will save the file's in the httpfilecollection and simply loop through and use the .SaveAs property to
save to your destination file. I can provide same code if you need..
Asp
c# You or someone please convert, I have not done vb in ages :P
protected void Button1_Click(object sender, EventArgs e)
{
HttpFileCollection hfc = Request.Files;
for(int i =0; i != hfc.Count; i++)
{
hfc[i].SaveAs(@"D:\MyFolder\"+ hfc[i].FileName);
}
}
In production , this would require your server to have folder rights.
edited May 12 at 4:20 answered May 12 at 4:14
I have tried to use your code as you suggested but I am not able to select multiple files. In fact first I got the
warning that multiple should be followed by = sign. So I changed it to multiple = "true". But still I am not able to
select multiple files. Vishal May 12 at 14:34
What browser are you using? Chris BucklerMay 12 at 20:30
I am using IE 10 Vishal May 12 at 21:15
Not sure what to tell you good sir, I just re copied back in the code and I can shift + multiple files into the upload
control. Chris BucklerMay 13 at 14:35
Not the answer you're looking for? Browse other questions tagged asp.net vb.net
file-upload or ask your own question.
http://stackoverflow.com/questions/askhttp://stackoverflow.com/questions/tagged/file-uploadhttp://stackoverflow.com/questions/tagged/vb.nethttp://stackoverflow.com/questions/tagged/asp.nethttp://stackoverflow.com/questions/16503823/about-uploading-multiple-files-and-giving-the-filename-to-fileupload-control-pro#comment23727675_16504128http://stackoverflow.com/users/591285/chris-bucklerhttp://stackoverflow.com/questions/16503823/about-uploading-multiple-files-and-giving-the-filename-to-fileupload-control-pro#comment23706045_16504128http://stackoverflow.com/users/2284240/vishalhttp://stackoverflow.com/questions/16503823/about-uploading-multiple-files-and-giving-the-filename-to-fileupload-control-pro#comment23705256_16504128http://stackoverflow.com/users/591285/chris-bucklerhttp://stackoverflow.com/questions/16503823/about-uploading-multiple-files-and-giving-the-filename-to-fileupload-control-pro#comment23699053_16504128http://stackoverflow.com/users/2284240/vishalhttp://stackoverflow.com/posts/16504128/revisionshttp://msdn.microsoft.com/en-us/library/system.web.httpfilecollection.aspxhttp://stackoverflow.com/questions/tagged/file-uploadhttp://stackoverflow.com/questions/tagged/vb.nethttp://stackoverflow.com/questions/tagged/asp.nethttp://stackoverflow.com/users/591285/chris-bucklerhttp://stackoverflow.com/users/591285/chris-bucklerhttp://stackoverflow.com/users/2284240/vishalhttp://stackoverflow.com/users/2284240/vishal -
7/28/2019 vb.net - About Uploading multiple files and giving the filename to fileupload control programatically in asp.pdf
3/3
6/20/13 vb.net - About Uploading multiple files and giving the filename to fileupload control programatically in asp.net - Stack Overflow
stackover flow.com/questions/16503823/about-uploading-mul tiple- fi les-and-giving-the- fi lename-to- fi leupload-control -pro 3/3