Hi all,
While you have all been diligently trying to sort out the problems I have been having with uploading files to the server as well as a record onto a database in my previous post:
I've been looking for alternative methods that may be easier. I have found something that looks as though it will work well. The code uploads the file to the directory that I want. Now what I need to do is to source the file through a record in the database.
I found the ASP File uploade here.
I have managed to integrate it into my ASP Form, but the problem I am now having is trying to get the text placed into the field that will allow me to show the image on the review pages. Below is the code at the start of the page:
The next section of code is what I have placed into the form so that the user can browse for the file, hit the upload button and upload the file.
Now, what I was hoping to acheive was that when the user clikced on the upload button and the file uploaded to the server, I wanted to place into a hidden field the text required to source the image in a review page. see below (although this field is not hidden)
This is where I am at at the moment. I don't what to place or where to get the text into the field. ANy help would be apreciated
Cheers
Dean
-------------------------------------------------------------
"The most overlooked advantage of owning a computer is that if they foul up there's no law against whacking them around a bit."
While you have all been diligently trying to sort out the problems I have been having with uploading files to the server as well as a record onto a database in my previous post:
I've been looking for alternative methods that may be easier. I have found something that looks as though it will work well. The code uploads the file to the directory that I want. Now what I need to do is to source the file through a record in the database.
I found the ASP File uploade here.
I have managed to integrate it into my ASP Form, but the problem I am now having is trying to get the text placed into the field that will allow me to show the image on the review pages. Below is the code at the start of the page:
Code:
<!-- #include file="freeaspupload.asp" -->
<%
' ****************************************************
' Change the value of the variable below to the pathname
' of a directory with write permissions, for example "C:\Inetpub\[URL unfurl="true"]wwwroot"[/URL]
Dim uploadsDirVar
uploadsDirVar = "D:\[URL unfurl="true"]wwwroot\calvaryaog.org.au\www\database\images"[/URL]
' ****************************************************
' Note: this file uploadTester.asp is just an example to demonstrate
' the capabilities of the freeASPUpload.asp class. There are no plans
' to add any new features to uploadTester.asp itself. Feel free to add
' your own code. If you are building a content management system, you
' may also want to consider this script: [URL unfurl="true"]http://www.webfilebrowser.com/[/URL]
function OutputForm()
%>
<form name="frmSend" method="POST" enctype="multipart/form-data" action="uploadTester.asp" onSubmit="return onSubmitForm();">
<input name="attach1" type="file" size=35><br>
<input style="margin-top:4" type=submit value="Upload">
</form>
<%
end function
function TestEnvironment()
Dim fso, fileName, testFile, streamTest
TestEnvironment = ""
Set fso = Server.CreateObject("Scripting.FileSystemObject")
if not fso.FolderExists(uploadsDirVar) then
TestEnvironment = "<B>Folder " & uploadsDirVar & " does not exist.</B><br>The value of your uploadsDirVar is incorrect. Open uploadTester.asp in an editor and change the value of uploadsDirVar to the pathname of a directory with write permissions."
exit function
end if
fileName = uploadsDirVar & "\test.txt"
on error resume next
Set testFile = fso.CreateTextFile(fileName, true)
If Err.Number<>0 then
TestEnvironment = "<B>Folder " & uploadsDirVar & " does not have write permissions.</B><br>The value of your uploadsDirVar is incorrect. Open uploadTester.asp in an editor and change the value of uploadsDirVar to the pathname of a directory with write permissions."
exit function
end if
Err.Clear
testFile.Close
fso.DeleteFile(fileName)
If Err.Number<>0 then
TestEnvironment = "<B>Folder " & uploadsDirVar & " does not have delete permissions</B>, although it does have write permissions.<br>Change the permissions for IUSR_<I>computername</I> on this folder."
exit function
end if
Err.Clear
Set streamTest = Server.CreateObject("ADODB.Stream")
If Err.Number<>0 then
TestEnvironment = "<B>The ADODB object <I>Stream</I> is not available in your server.</B><br>Check the Requirements page for information about upgrading your ADODB libraries."
exit function
end if
Set streamTest = Nothing
end function
function SaveFiles
Dim Upload, fileName, fileSize, ks, i, fileKey
Set Upload = New FreeASPUpload
Upload.Save(uploadsDirVar)
' If something fails inside the script, but the exception is handled
If Err.Number<>0 then Exit function
SaveFiles = ""
ks = Upload.UploadedFiles.keys
if (UBound(ks) <> -1) then
SaveFiles = "<B>Files uploaded:</B> "
for each fileKey in Upload.UploadedFiles.keys
SaveFiles = SaveFiles & Upload.UploadedFiles(fileKey).FileName & " (" & Upload.UploadedFiles(fileKey).Length & "B) "
next
else
SaveFiles = "The file name specified in the upload form does not correspond to a valid file in the system."
end if
end function
%>
<HTML>
<HEAD>
<TITLE>Test Free ASP Upload</TITLE>
<style>
BODY {background-color: white;font-family:arial; font-size:12}
</style>
<script>
function onSubmitForm() {
var formDOMObj = document.frmSend;
if (formDOMObj.attach1.value == "" && formDOMObj.attach2.value == "" && formDOMObj.attach3.value == "" && formDOMObj.attach4.value == "" )
alert("Please press the browse button and pick a file.")
else
return true;
return false;
}
</script>
Code:
<%
Dim diagnostics
if Request.ServerVariables("REQUEST_METHOD") <> "POST" then
diagnostics = TestEnvironment()
if diagnostics<>"" then
response.write diagnostics
response.write "<p>After you correct this problem, reload the page."
else
OutputForm()
end if
else
OutputForm()
response.write SaveFiles()
end if
%>
Code:
<input name="ImgSrc" type="text" class="menutxt" value=<% response.Write("<img src=' & fileName & '>")%> size="50">
This is where I am at at the moment. I don't what to place or where to get the text into the field. ANy help would be apreciated
Cheers
Dean
-------------------------------------------------------------
"The most overlooked advantage of owning a computer is that if they foul up there's no law against whacking them around a bit."