473,569 Members | 2,634 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Browse a file and then upload it to mysql

3 New Member
Hi

Can anyone please help me. I am trying to browse for a file. I would like the file path name to be shown on a text box. Using the upload button I would then like to save the file on mysql. is is the code I have don so far.

Expand|Select|Wrap|Line Numbers
  1. Private Function LoadFile(sFile As String) As Boolean
  2.     Dim filenum
  3.  
  4.     Text2.Tag = sFile
  5.  
  6.     ' Make sure a file is specified.
  7.     If sFile = "" Then
  8.         LoadFile = False
  9.         Exit Function
  10.     End If
  11.  
  12.     ' Make sure the file exists before trying to open it.
  13.     If Dir(sFile) = "" Then
  14.         LoadFile = False
  15.         Exit Function
  16.     End If
  17.  
  18.     ' Read the collection from a text file.
  19.     ' Get a free file number
  20.     filenum = FreeFile
  21.  
  22.     ' Open sfile for input
  23.     Open sFile For Input As filenum
  24.     On Error Resume Next
  25.     ' Read the contents of the file into TextBox1
  26.     Text2.Text = Input(LOF(filenum), filenum)
  27.     If Err Then
  28.         Text2.Text = "Error Loading File. Invalid Format"
  29.         Close filenum
  30.         LoadFile = False
  31.     End If
  32.     ' Close the file
  33.     Close filenum
  34.  
  35.     LoadFile = True
  36. End Function
  37.  
  38.  
  39.       Private Sub Command10_Click()
  40.       'Opens a Treeview control that displays the directories in a computer
  41.         Command1.Visible = True
  42.  
  43.          Dim lpIDList As Long
  44.          Dim sBuffer As String
  45.          Dim szTitle As String
  46.          Dim tBrowseInfo As BrowseInfo
  47.  
  48.          szTitle = "File to Upload:"
  49.         With tBrowseInfo
  50.             .hWndOwner = Me.hwnd
  51.             .lpszTitle = lstrcat(szTitle, "")
  52.             .ulFlags = BIF_RETURNONLYFSDIRS + BIF_DONTGOBELOWDOMAIN
  53.          End With
  54.  
  55.          lpIDList = SHBrowseForFolder(tBrowseInfo)
  56.  
  57.          If (lpIDList) Then
  58.             sBuffer = Space(MAX_PATH)
  59.             SHGetPathFromIDList lpIDList, sBuffer
  60.             sBuffer = Left(sBuffer, InStr(sBuffer, vbNullChar) - 1)
  61.  
  62.           'Text1.Text = sBuffer
  63.           txtFields(14).Text = sBuffer
  64.             MsgBox sBuffer
  65.          End If
  66.  
  67.  
  68. End Sub
Feb 14 '08 #1
1 1191
debasisdas
8,127 Recognized Expert Expert
What is the problem with the code ?

Why are you reading the contest of the file ?
Feb 15 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
9911
by: Ron Brennan | last post by:
Good afternoon. The entire task that I'm trying to achieve is to allow a user to browse and upload multiple files simultaneously, hiding the Browse button of <input> tags of type="file" and replacing it with a button of my own background color and text. The file paths I'd like displayed in a textarea and then the files uploaded at once.
5
5456
by: Ron Brennan | last post by:
Good afternoon. The entire task that I'm trying to achieve is to allow a user to browse and upload multiple files simultaneously, hiding the Browse button of <input> tags of type="file" and replacing it with a button of my own background color and text. The file paths I'd like displayed in a textarea and then the files uploaded at once.
21
66782
by: strutsng | last post by:
<input type="file"> only allows the user to browse for files. How about "browse for folder" dialog? Can html/javascript do that? I couldn't find any syntax for that. If not, please advise what are the other approaches. please advise. thanks!!
5
5891
by: Codeman II | last post by:
Hi there, I am building a form where the user must upload a picture and fill in his details. Now I have a problem as all of this is on the same form. How will I be able to have the Browse button to open the "file browse" dialog and the Submit button to submit the form data.
0
1464
by: jason | last post by:
some confusion here. The below code allows me to save a local file to my web server and somehow because the field type is file a local file browse button is rendered. I'm trying to figure out how to incorporate this code into an existing asp.net (vb). In my code "C:\Uploads\uploadedfile.txt" is dynamcially set to a value pulled from a...
2
3816
by: johnny | last post by:
hi all, I have troubles with a css styled form: I cannot make an upload field staying into a fixed column , say 100 pixels wide. It could be enough to have the file browse button below the upload field, however I do not know how to do that. The file browse button is always on the right of the upload field and it always goes out of the...
18
2320
by: walterbyrd | last post by:
I am trying to develop an app where: the same file, in the same place, will be uploaded, and then processed. Everything I can find about uploading a file, uses a form that requires the user to either manually enter the path and file name, or to browse for the file. I do not want that. Ideally, I want the user to click on a link, and the...
3
1558
by: beary | last post by:
Sorry if this seems like a stupid question, but... The script I am currently using puts a number of input type=file boxes on the page, and then loops through and processes each uploaded file. It works perfectly. However, each time I want to upload many files, I need to manually click Browse and select each file. This is annoying. I'm trying...
0
7615
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8130
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7677
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
6284
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5514
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3653
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3643
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2115
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
940
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.