Hi Master CroCrew,
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 - <%
-
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>
2 2895 jhardman 3,406
Recognized Expert Specialist
Hey hotflash,
Just a reminder, please put your code inside code tags (notice the button marked - #) This makes it much easier to read.
In order to update rather than add new, you need to do two things:
1- open the recordset and make sure you are on the record you want to update. This is the hard part, you will need to either modify the SQL query so that you only return the one record you want (the preferred way), or open all the records and scroll through until you find the record you want to update (takes longer to run, but may be easier for a newbie to code).
2- remove the "RS.addNew" line. This is the easy part, as long as the recordset doesn't add a new record, you will overwrite the previous data.
Let me know if this helps.
Jared
Hi Jared,
Thanks for your replying. I have tried both methods you recommended but still have no luck. There are about 30 records on the database. We only need to update the record that is needed. Honestly, this thing is way over my head.
Any other recommendation? There is a link to the code above, wonder if you can try yourself to see if you have any luck or not. The file that I used is
db-file-to-disk. Let's say, once the file is uploaded to the server, and there is an entry in the database. Try to update the Description to see how is it going to work. Thanks once again for your outstanding support.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: matt |
last post by:
I have compiled some code, some written by me, some compiled from
various sources online, and basically i've got a very simple flat file
photo gallery. An upload form, to upload the photos and give them a
caption, storing the caption and filename in a text file. It's a bit
buggy when removing the photos and captions from the file, and also in
displaying them on the delete page. you can see it in action at
www.4am.com.au/gallery/upload.php...
|
by: Jake |
last post by:
Hi group,
I am trying to build a page that allows uploading
My ISP only supports Smartupload
I am testing on a small hubbed local network, with PWS
Any help is appreciated.
---------------------
'rqstupl.asp contents
<HTML>
|
by: bballr |
last post by:
What I am trying to do is to take the contents of a very large text
file and place it into a LONGTEXT field in a database. I am looking
for a solution using the C API to help me handle this. The code I use
right now is very ineffecient. I basically use a VERY large character
array that is like 600,000 characters long and store an UPDATE query to
the database in this. I place the contents of the file being uploaded
into this query where...
|
by: Jim Michaels |
last post by:
after a file upload, $_FILES is not populated but $_POST is. what's going
on here?
$_POST=C
$_POST=C
$_POST=C
$_POST=C:\\www\\jimm\\images\\bg1.jpg
$_FILES=
$_FILES=
$_FILES=
|
by: Vic Spainhower |
last post by:
Hello,
I am trying to do a FTP file upload which works fine on my localhost but on
my ISP server it fails. I can't seem to find where I can go to find the
specific cause of the failure. In both cases the file is being transmitted
to the same FTP server and using the same PHP script so it shouldn't be a
file size or login credentials problem. Could someone please help me out and
give me some ideas what is wrong.
I would really...
| |
by: aris1234 |
last post by:
hello..
How to upload image file in page update ..??
i have logic like this :
if user upload new image then old image must delete and update DB used new name
if user not upload new image then old image no delete.
code form like this (i dontknow this code right or wrong, please correction if wrong) :
|
by: siyaverma |
last post by:
i am trying to upload csv file from user's computer to main server
the code i am using is
if(((isset($_GET)) && ($_GET=="yes")) )
{
$typefield = $_GET;
echo "<form enctype=\"multipart/form-data\" action=\"$PHP_SELF\" method=\"POST\">
|
by: amritranjan |
last post by:
This is my Jsp code for image upload in database:
-----------Upload.jsp----------------
<html>
<head>
<title>Account Details </title>
</head>
<body bgproperties="fixed" bgcolor="#CCFFFF">
<form method="POST" action="UploadPicture.jsp" enctype="multiform/form-data">
|
by: hotflash |
last post by:
Hi All,
I found the best pure ASP code to upload a file to either server and/or MS Access Database. It works fine for me however, there is one thing that I don't like and have tried to fix but don't have any luck is to do a form validation. This script requires the files: db-file-to-disk.asp and _upload.asp. There is a DESCRIPTION field in the db-file-to-disk.asp file, what I want to do is the user has to field out this fied before...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
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 most users, this new feature is actually very convenient. If you want to control the update process,...
|
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 launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |