kazar
Apr 8th, 2006, 01:08 PM
Now, i'm afraid to make use of this code you must have your own website, since it requires server side-scripting.
First off you need to copy this code into a file on your server, preferably in the root site folder.
<%
dim filename,linewrite,fs,f,append
filename=request.QueryString("filename")
linewrite=request.QueryString("linewrite")
append=request.QueryString("append")
set fs=Server.CreateObject("Scripting.FileSystemObject")
set f=fs.OpenTextFile(Server.MapPath(filename),append,true)
f.WriteLine(linewrite)
f.close
set fs=nothing
set f=nothing
%>
Then you download the project included, which contains one form, with one inet control, one label and a button.
The code for the form is:
Dim filename As String
Dim serverfile As String
Dim aspuploaderurl As String
Dim lincount As Long
Dim urlstring As String
Dim i As Long
Dim append As String
Private Sub upload_file_Click()
filename = InputBox("Enter Filename")
serverfile = InputBox("Enter Server Path")
aspuploaderurl = InputBox("Enter Uploader File URL")
On Error GoTo skipfileread
Open filename For Input As #1
Do
Line Input #1, countstring
lincount = lincount + 1
Loop
Close #1
skipfileread:
Close
On Error Resume Next
Open filename For Input As #1
For i = 1 To lincount
status_label = Str(FormatNumber((i / lincount) * 100, 3)) + "%"
DoEvents
If i = 1 Then
append = "2"
Else
append = "8"
End If
On Error Resume Next
Line Input #1, writeline
urlstring = aspuploaderurl
urlstring = urlstring + "?" + "filename=" + serverfile + "&" + "append=" + append + "&" + "linewrite=" + writeline
uploadinet.OpenURL (urlstring)
Next i
Close #1
skipall:
If Err <> 0 Then
errbox = MsgBox("Error Encountered", vbCritical)
End If
End Sub
It works pretty well. I have got it doing a 739 line file in 50 seconds.
It works by line, not by size. There is a max line length though, so use files where the data is on seperate lines. Note: this only works for text based files - .txt, .html, etc
I use it to offer an online backup service on a database program i'm working on, and it has had good response from my users. To get the file back into vb is much easier, just use an INet Control.
Note on serverfilename syntax:
whatever.txt - writes to the same folder as the uploader file
whatever/whatever.txt - writes to one folder up from the upload file (don't need start forward slash.
../whatever.txt - writes to one folder below the uploader file.
Thats it. I find it a very useful tool, and i hope you will too.
First off you need to copy this code into a file on your server, preferably in the root site folder.
<%
dim filename,linewrite,fs,f,append
filename=request.QueryString("filename")
linewrite=request.QueryString("linewrite")
append=request.QueryString("append")
set fs=Server.CreateObject("Scripting.FileSystemObject")
set f=fs.OpenTextFile(Server.MapPath(filename),append,true)
f.WriteLine(linewrite)
f.close
set fs=nothing
set f=nothing
%>
Then you download the project included, which contains one form, with one inet control, one label and a button.
The code for the form is:
Dim filename As String
Dim serverfile As String
Dim aspuploaderurl As String
Dim lincount As Long
Dim urlstring As String
Dim i As Long
Dim append As String
Private Sub upload_file_Click()
filename = InputBox("Enter Filename")
serverfile = InputBox("Enter Server Path")
aspuploaderurl = InputBox("Enter Uploader File URL")
On Error GoTo skipfileread
Open filename For Input As #1
Do
Line Input #1, countstring
lincount = lincount + 1
Loop
Close #1
skipfileread:
Close
On Error Resume Next
Open filename For Input As #1
For i = 1 To lincount
status_label = Str(FormatNumber((i / lincount) * 100, 3)) + "%"
DoEvents
If i = 1 Then
append = "2"
Else
append = "8"
End If
On Error Resume Next
Line Input #1, writeline
urlstring = aspuploaderurl
urlstring = urlstring + "?" + "filename=" + serverfile + "&" + "append=" + append + "&" + "linewrite=" + writeline
uploadinet.OpenURL (urlstring)
Next i
Close #1
skipall:
If Err <> 0 Then
errbox = MsgBox("Error Encountered", vbCritical)
End If
End Sub
It works pretty well. I have got it doing a 739 line file in 50 seconds.
It works by line, not by size. There is a max line length though, so use files where the data is on seperate lines. Note: this only works for text based files - .txt, .html, etc
I use it to offer an online backup service on a database program i'm working on, and it has had good response from my users. To get the file back into vb is much easier, just use an INet Control.
Note on serverfilename syntax:
whatever.txt - writes to the same folder as the uploader file
whatever/whatever.txt - writes to one folder up from the upload file (don't need start forward slash.
../whatever.txt - writes to one folder below the uploader file.
Thats it. I find it a very useful tool, and i hope you will too.