I found a good PURE ASP that will allow you to upload 10MB file to the server and the file contents such as Network, Author, Title, etc... will insert to MS Access at the same time.
Below is a working script that I used. Let's say after the file is uploaded to the server and a record created with the file contents above to the MS Access (using the script below). If I want to UPDATE that record let's say, change the Author from Mr. A to Mr. B, the new file will overwrite the existing one on the server OK however, how can I modify the RS.AddNew code to make it to UPDATE the MS Access contents such as Author as well? Thank you very much for your OUTSTANDING SUPPORT so far. FYI that the website where the original script located is
http://www.planet-source-code.com/vb...=8225&lngWId=4
Expand|Select|Wrap|Line Numbers
- <%
- Server.ScriptTimeout = 5000
- Dim Form: Set Form = New ASPForm %><!--#INCLUDE FILE="_upload.asp"--><%
- Server.ScriptTimeout = 1000
- Form.SizeLimit = &HA00000'10MB
- If len(Request.QueryString("UploadID"))>0 then
- Form.UploadID = Request.QueryString("UploadID")'{/b}
- End if
- Const fsCompleted = 0
- Dim UploadID, PostURL
- UploadID = Form.NewUploadID
- 'Send this ID as a UploadID QueryString parameter to this script.
- PostURL = Request.ServerVariables("SCRIPT_NAME") & "?UploadID=" & UploadID'{/b}
- %>
- <HTML>
- <HEAD>
- <TITLE>Testing</TITLE>
- </HEAD>
- <BODY BGCOLOR="#FFFFFF">
- <TABLE>
- <BR>
- <DIV ALIGN="LEFT">
- <FORM NAME="file_upload" METHOD="POST" ENCTYPE="multipart/form-data" OnSubmit="return ProgressBar();" Action="<%=PostURL%>">
- <FONT FACE="HELVETICA,HELV,ARIAL" SIZE="2" COLOR="FF0000">** Denotes REQUIRED FIELD. Please DO NOT press the "Upload File" button twice.</FONT>
- <P></P>
- <TR>
- <TD ALIGN="LEFT"><FONT FACE="HELVETICA,HELV,ARIAL" SIZE="2"> Network</FONT></FONT><FONT FACE="HELVETICA,HELV,ARIAL" SIZE="1" COLOR="FF0000"> ** </FONT></TD>
- <TD>
- <SELECT NAME="Network" ID="Network">
- <OPTION VALUE> </OPTION>
- <OPTION VALUE="TEST1"> TEST1 </OPTION>
- <OPTION VALUE="TEST2"> TEST2 </OPTION>
- </SELECT>
- <FONT FACE="HELVETICA,HELV,ARIAL" SIZE="2"> Author</FONT><FONT FACE="HELVETICA,HELV,ARIAL" SIZE="1" COLOR="FF0000"> ** </FONT>
- <INPUT TYPE="TEXT" NAME="Author" SIZE="40" VALUE="" ID="Author">
- <FONT FACE="HELVETICA,HELV,ARIAL" SIZE="2"> Revision</FONT><FONT FACE="HELVETICA,HELV,ARIAL" SIZE="1" COLOR="FF0000"> ** </FONT>
- <INPUT TYPE="TEXT" NAME="Revision" SIZE="8" VALUE="" ID="Revision">
- </TD>
- </TR>
- <TR>
- <TD ALIGN="LEFT"><FONT FACE="HELVETICA,HELV,ARIAL" SIZE="2"> Title</FONT><FONT FACE="HELVETICA,HELV,ARIAL" SIZE="1" COLOR="FF0000"> ** </FONT></TD>
- <TD><INPUT TYPE="TEXT" NAME="Title" SIZE="99" VALUE="" ID="Title"></TD>
- </TR>
- <TR>
- <TD ALIGN="LEFT"><FONT FACE="HELVETICA,HELV,ARIAL" SIZE="2"> File Name</FONT><FONT FACE="HELVETICA,HELV,ARIAL" SIZE="1" COLOR="FF0000"> ** </FONT></TD>
- <TD><INPUT TYPE="FILE" NAME="SourceFile" SIZE="86" VALUE="" ID="SourceFile"></TD>
- </TR>
- </TABLE>
- <CENTER>
- <BR>
- <INPUT CLASS="Table_Blue" TYPE="SUBMIT" VALUE="UPLOAD FILE"> <INPUT CLASS="Table_Blue" TYPE="RESET" VALUE="CLEAR FORM">
- </CENTER>
- <BR>
- <CENTER>
- <%
- If Form.State = fsCompleted Then 'Completed
- 'Create destination path+filename for the source file.
- Dim DestinationPath, DestinationFileName
- DestinationPath = Server.mapPath("MOPsUpload")
- DestinationFileName = DestinationPath & "\" & Form("SourceFile").FileName
- 'Open recordset to store uploaded data
- Dim RS: Set RS = OpenUploadRS
- 'Store extra info about upload to database
- RS.AddNew
- RS("UploadDT") = Date()
- RS("Network") = Form.Texts.Item("Network")
- RS("Title") = Form.Texts.Item("Title")
- RS("Revision") = Form.Texts.Item("Revision")
- RS("Author") = Form.Texts.Item("Author")
- RS("SourceFileName") = Form("SourceFile").FilePath
- RS("DestFileName") = DestinationFileName
- RS("DataSize") = Form("SourceFile").Length
- '...
- RS.Update
- Dim Field: For Each Field in Form.Files.Items
- Next
- 'Save file to the destination
- Form("SourceFile").SaveAs DestinationFileName
- Response.Write("<FONT FACE=""HELVETICA,HELV,ARIAL"" COLOR=""#FF0000"" SIZE=""2"">Uploaded successfuly.")
- Response.Write("</FONT>")
- ElseIf Form.State > 10 then
- Const fsSizeLimit = &HD
- Select case Form.State
- case fsSizeLimit: response.write "<br><Font Color=red>Source form size (" & Form.TotalBytes & "B) exceeds form limit (" & Form.SizeLimit & "B)</Font><br>"
- case else response.write "<br><Font Color=red>Some form error.</Font><br>"
- end Select
- End If'Form.State = 0 then
- Function OpenUploadRS()
- Dim RS : Set RS = CreateObject("ADODB.Recordset")
- 'Open dynamic recordset, table Upload
- RS.Open "MOPs", GetConnection, 2, 2
- Set OpenUploadRS = RS
- End Function
- Function GetConnection()
- Set Conn = Server.CreateObject("ADODB.Connection")
- Conn.Open "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & Server.MapPath("YourDatabase.mdb") & "; Jet OLEDB:Database Password=happy"
- set GetConnection = Conn
- End function
- %>
- </CENTER>
- <BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR>
- </FORM>
- <SCRIPT language=javascript>
- //Open window with progress bar.
- <!--
- function ProgressBar(){
- var ProgressURL;
- ProgressURL = 'progress.asp?UploadID=<%=UploadID%>';
- var Network;
- var Revision;
- var Author;
- var Title;
- var SourceFile;
- Network = file_upload.Network.value;
- Revision = file_upload.Revision.value;
- Author = file_upload.Author.value;
- Title = file_upload.Title.value;
- SourceFile = file_upload.SourceFile.value;
- if (Network.length==0)
- {
- alert('Reason: The "Network" may contain invalid characters or is blank.');
- file_upload.Network.focus();
- return false;
- }
- else
- {
- var v = window.open(ProgressURL,'_blank','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,width=355,height=140');
- return true;
- }
- //return;
- }
- // -->
- </SCRIPT>
- </DIV>
- </TD>
- </BODY>
- </HTML>