Link to home
Start Free TrialLog in
Avatar of computer1000
computer1000

asked on

Uploading in FrontPage 2000/Access 2000

I am designing a dating service website. When a user logs in with username and password and purchase a membership to view a lit of members that are single and has a photo of them with their own profile. A user can build his or her own profile by uploading a small photo of himself of herself. I can write a code for uploading a image into the Microsoft Access by using third party component with ASP. I can write a code to save the picture file to the image folder and upload the name of the picture file to the database.. The question is that I could not figure out how to use third party component in the FrontPage 2000 with ASP. Is there another way to upload images to the database (MS Access 2000 and FrontPage 2000), not using ASP or scripting?
Avatar of ClassyLinks
ClassyLinks
Flag of Canada image

Not using ASP or scripting???  No.

What third party component are you using?  I have clients upload pictures to the image files all the time and have a little script that inserts the value to the database at the same time.

FrontPage is VERY compatible with ASP...you just need to do the edit in HTML mode.  You will probably have no problem using your Third Party tool.  How about giving me some more info and we can figure it out here.
Avatar of computer1000
computer1000

ASKER

I am using free ASP Simple Upload component that is from http://www.asphelp.com/ASPSimpleUpload/Default.Asp.

>>I have clients upload pictures to the image files all the time and have a little script that inserts the value to the database at the same time.

Can you provide me the examples for that? Source code?

I do not want to store the images in the database. I am using to store the pathname and filename in a table and the image on the file server. For example, I have a picture file name "dog.jpg". I save that picture file to the image folder. 'image/dog.jpg'. I upload the name of the picture file to the database 'dog.jpg' in myimage field in the mytable table. I wrote a very small program for uploading an image into the database (Access 2000) by using ASP with the free third party component. I test it, and it worked very well. But, the question is how to use my source code in FrontPage 2000? How do I publish my pages including 3rd party component (ocx or dll) using Frontpage 2000? I do have free web hosting that supports FrontPage Extension server but does not support ASP. On the other hand, I do have web hosting that supports ASP but not FrontPage Extension server..

Here is my code.

<!-- #include file="adovbs.inc" -->
<%
     
 
  Dim upl, NewFileName, theConn, rs
  Set upl = Server.CreateObject("ASPSimpleUpload.Upload")
  Set cn = Server.CreateObject("ADODB.Connection")
  theConn = "Provider=Microsoft.Jet.OLEDB.4.0; " & _
         "Data Source=C:\mytable.mdb;"
  cn.Open theConn
  Set rs = Server.CreateObject("ADODB.Recordset")
  rs.Open "mytable", theConn, 1, 3
     If Len(upl.Form("File1")) > 0 Then
 
         NewFileName = "/image/" & upl.ExtractFileName(upl.Form("File1"))
         If upl.SaveToWeb("File1", NewFileName) Then
             Response.Write("File successfully written to disk.")
         Else
             Response.Write("There was an error saving the file to disk.")
         End If
         rs.AddNew
  rs("myimage") = upl.ExtractFileName(upl.Form("File1"))

 
  rs.Update
         
     End If
     %>
 
     <html><head><title>ASP Simple Upload Example #1</title></head></title>
 
     <body>
<form method="POST" action="Example1.Asp" enctype="multipart/form-data">
Select a file to upload: <input type="file" name="File1" size="30">
     <input type="submit" name="submit" value="Upload Now">
     </form>
     </body>
     </html>

I'm not sure I'm understanding you correctly.

You have already written the code.  It uploads the images to the appropriate folder and adds the file name to the database.  Beautiful!

-->But, the question is how to use my source code in FrontPage 2000? How do I
publish my pages including 3rd party component (ocx or dll) using Frontpage 2000?

I'd forget about the publish command unless you are using FP components (counter, form submission, db results wizard) on the same page. ---which you aren't from the looks of things.

All you need to do is ftp your code to the server that supports ASP.

Does that answer your question, or am I confused now??
Well, the owner of the Web Design and Hosting asked me 'how to upload an image into the database' only part because she could not figure it out all week long. She is using FrontPage 2000 and Microsoft Access 2000. I assume that she's using FrontPage components for other parts/pages which I am not involved in. I can do it by ftpping my code to the server that supports ASP. But, I just want to test it by publishing my code/pages using FrontPage 2000 if the owner is using FrontPage components for other pages.. Do you understand what I am saying? If no, please tell me and I will explain more to you.
You said that you have clients uploading pictures to the images files and having a small script that inserts the value into the database.

Can you tell me how to do that besides my code using 3rd party component so that way I can learn something from you. I'd be very happy to increase 50 points or more for that and if you provide me an excellent explanation.
I use Persists upload on my site:

<body>
<%
If Request.QueryString("action") = "upload" Then
Set Upload = Server.CreateObject("Persits.Upload.1")
Upload.Save ("folderpath goes here")
set conn = server.createobject("adodb.connection")
conn.open "DSN=classidb"
addSQL = "INSERT INTO planner (filename) VALUES ('" & File.ExtractFileName  & "')"
conn.execute addSQL
%>
     <center>
     <h4>File was successfully uploaded!</h4>    
<%          
End If
%>

<form name="frmUpload" enctype="multipart/form-data" method="POST" action="WPupload.asp?action=upload">
   <h1 align="center"><b><font color="#CC9900">Select a file to upload:&nbsp;</font></b></h1>
  <p align="center">
       <input type="file" name="upload" size="38"></p>
  <p align="center"><input type="submit" value="Upload Now!"></p>
</form>

</body>
Classlinks: Never mind on my previous comments! Before restarting my computer, it did not work when I tested my page in FrontPage 2000 offline. It works fine after restarting! I assume that you have your own web hosting that supports FrontPage extension server and ASP features. Since I don't have a web hosting that supports ASP/extension server, I am asking you to publish my page using FrontPage 2000 for a test. Please tell me if it's working or not. Thank you very much.
The problem is that if you want to insert the value into the db..you need some server side scripting....ASP.

I suppose you could fight with FP and the database wizard to do that part, but the uploading you will need the 3rd party tool.

She doesn't have ASP??   How about cgi??  There are cgi scripts that will do this whole thing, I'm sure.


She can still publish, naturally, put without asp on he server neither upload component (your or min) is any good.
I never publish my pages.  Unless you are using an FP component, your script will work regardless of whether you FTP or publish.
ClassyLinks: Thanks very much!!! You have been so very helpful to me! I will talk with the owner about ASP, CGI, etc.. now and I will let you know by tonight. Thanks a lot!
The owner told me that the server from which she host allows ASP. She thinks that it also allows 3rd party components but she does not know for sure. She said that she's going through tools in Frontpage 2000 to set up the database on Windows NT. I will send her my source code with the 3rd party component so she will test it by herself. If it does not work on the server, I guess there is one way -- using CGI scripts without 3rd party component. Can you wait till tomorrow evening? But, I have a question.. When she's going through tools in Frontpage 2000, what kind of database connection for using a database with FrontPage 2000? I think for FrontPage, it should be DSN? DSN-less? Is Persists upload component free? Is it good?
I know at least one Expert on this site disagrees with me but:

The connection FP make with databases is NASTY!  IMHO for the amount of time it takes to learn how to make a proper connection with ASP (which is really what FP uses) you will save yourself many migraines!

Check some of the open questions here.  How many of them are because the user need to "change" or manipulate a database connection or form results that they originally set up with FP??  If you are doing anything out of the ordinary it is a NIGHTMARE!

Persists upload is good....the server might already have it installed....you just have to check which 3rd party componenets they support....most host have a list of supported components on their website.

Your script will work for her, even if she is using FP for her other pages db connections.  Whether she "publishes" or ftp's will not make a difference to this page.

Because she supports ASP, stay away from the CGI...much harder to program, more files on the server, and a much less intuitive language (again, my opinion.).
computer1000...are you there....what did you decide??
Help me!!!!!! I will give 50 points more!

She said she does not have ASP components, so I had written the code without using 3rd party component.. in VBSCRIPT. I test it offline...perfectly! She's using through database wizards in FP to set up the database for other pages. I wrote the code to make the connection with ASP for uploading images into the database (newphoto page). I tested it, and it went fine. I ftpped to her site/server. I tested it there and got an error.. It has to do with the DSN thing!

Here are my codes .. for connection and recordset each.

For Each File In Uploader.Files.Items
  File.SaveToDisk Server.MapPath("/images/")
  Set cn = Server.CreateObject("ADODB.Connection")
  cn.Open "DSN=dayweb"
 
  addSQL = "INSERT INTO Contacts (MemberPhoto) VALUES ('" & File.FileName & "')"
  cn.execute addSQL
Next
Set cn = nothing

----------------------------------------------------------

For Each File In Uploader.Files.Items
  File.SaveToDisk Server.MapPath("/images/")

  Set rs = Server.CreateObject("ADODB.Recordset")
  rs.Open "Select * FROM Contacts", "DSN=allweb", 3, 2
  rs.AddNew
  rs("MemberPhoto") = File.FileName
  rs.Update
Next

These above codes are the same thing.. They are working fine on my machine. But when I ftpped them to the site/server. I got the error:

Microsoft OLE DB Provider for ODBC Drivers error '80040e37'

[Microsoft][ODBC Microsoft Access Driver] The Microsoft Jet database engine cannot find the input table or query 'Contacts'. Make sure it exists and that its name is spelled correctly.

Sometimes the error says.. "Could not find the output table "Contacts".. when I modified my code...



But, I checked the folders in the server/site:

For her domain host, she set up a dsn name with them called "allweb'
"Members.mdb" database is sitting at the fpdb directory on the server.
The database name is "Members".
The table name is "Contacts".
The field name is "MemberPhoto".

In the allwebsite (think of c: drive)...
fpdb folder (directory) -- members.mdb
test folder (directory) -- several pages including newphoto.asp, index.htm, browse.asp.

Most of the pages that she created is through FP. She and I test all of the pages she created in Fp. They are so nice. But, I create a newphoto page by using ASP. It is not sooo nice because of DSN thing.

I am still confused to this dsn thing. I have not done the frontpage with database before and she has not done with ASP with database before. We are having problems with the dsn thing. She is working strictly from off of her web host server, nothing from her system. All are done straight in the server, not on her harddrive.

I modified something to URL for DSN:

Set cn = Server.CreateObject("ADODB.Connection")
strConn =  "Driver={Microsoft Access Driver (*.mdb)}; " & _
          "DBQ=URL=fpdb/Members.mdb"
cn.Open strConn


I tried to test it, but the site is down for now. Will my above code work on the site/server?
Please help me . I have been working on this for 3 days! Please help me. If you want more points, I will be happy to give you more points.
For example, The site is allweb.com. It has two folders -- fpdb directory and test directory. fpdb directory has Members.mdb database. test directory has newphoto.asp, index.htm, browser.asp, etc. dsn name on the domain host is allweb.

How do I find the right path of the database for dsn.
I need to find it. Tell me how to find the right path.. I think I use URL for that path, like the code I gave you above. ???
ASKER CERTIFIED SOLUTION
Avatar of ClassyLinks
ClassyLinks
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
She can use ASP but cannot use the 3rd party upload script because her web server does not support ASP components. Yes, she is hosting the site on her own server.
I will try testing your statement to see if it's working or not.. But, just now, we cannot view any asp pages witinin her site. She has to call her host to see if they are having a problem. I will let you know. Thank you soo much!
If it is only the ASP pages, they probably just have to restart ASP on the server.  Happened to me yesterday.

Let me know if that path works.
ClassLinky: She had her host fixed the problem on her server with the asp pages. She will move any asp work on another server, as she does not want to work on her server anymore with other asp pages.. Before she removed the particular folder which I am working from her server and will move it to another server, I tested it there. I got a few errors, but I fixed your dsn-less thing. It worked fine.

It is   strConn =  "Driver={Microsoft Access Driver (*.mdb)}; " & _
                   "DBQ=" & Server.Mappath ("/fpdb/Members.mdb")

I hope the script on another server will work.. Wait and see what will happen.

I will grade you by tonight. You will get 200 points for this with 'A'. Can you please accept my question from ASP? It is from https://www.experts-exchange.com/jsp/qManageQuestion.jsp?ta=asp&qid=20099030

Thank you. You are the best!
The connection should work on another computer AS LONG AS the files are in the same relative structure.

Let me know how it goes.
Thanks, ClassLinks.

The new server is down already!. I am frustrated. Just when she and I get everything switched over. The server will come back up tomorrow.

I have tested all three asp file upload scripts there, and they are not working unsuccessfully.

1. The server does not support ASP component ... or does support, as she said she does not know for sure..
2. When I write pure asp file upload code, I got an error message saying

Server object error 'ASP 0177 : 800a004c'

Server.CreateObject Failed

/timereporting/man/uploadclass.asp, line 120

The operation completed successfully.

But, I tested it on the old server, it worked fine. I still don't understand why it does not work on the new server.

3. I wrote another code for a file uploading windows script component (wsc -- see http://www.4guysfromrolla.com/webtech/012401-1.shtml) It worked fine when it uploads file name to the database, but it won't let me to save an image to the image folder. It said something about the permission.

All these code scripts I created are not working on the new server. But, I have tested it on my machine, all are working perfectly fine.

For me, using a 3rd party file upload component is better solution because it is easy to install and code. I don't know if that web server does support ASP components as the owner said she does not know for sure. I think I did not transfer anything to the server?  How do you transfer 3rd party component files to any server? I cannot think of something else of how to solve these problems..  Any ideas?
150 to 200 points
What is the server??  I'll go in and check out their packages and tell you what they support.

>>it uploads file name to the database, but it won't let me to save an image to the image folder

You may need to get them to give write permissions for this folder.

You cannot install any components on the server...the host has total control over that.  However, I'm willing to bet that they support something.  Again...let me know who they are and the level of her package and I'll see what I can find out.
>What is the server? You mean you want to know the name of the web server? like https://www.experts-exchange.com? If so, I would liek to email you for that.
sure:  webmaster@classylinks.ca
Classlinky: post your comments here. My email address is slow because of my connection. Thanks.
Ok...I'll have to wait until the host site is up before I can tell you what they can handle.
The site is up. Can you check the hosting company for me? Tell me what they can handle. Thanks.
It doesn't say anything about what they support on thier site  8-(  Only FP.
(sighing)... I guess I will have to ask the owner about the web server's packages. I just have started developing the website for one week with her. She knows FP only. I know ASP and a bit FP. I communicate with her via e-mail regularly. Anyway, thank you very much.
NP....All servers will support some kind of upload script either Persists, ASPUpload or some CGI thing.  They should also provide the ASP/whatever script for it.  All you need to do is find out which one.

Also...do a test ASP page, just to make sure she does in fact support it.

Something like:

<% test = "This server supports ASP"

response.write test

%>

If the page is blank, you know that the ASP doesn't work on the server.
The site is down!!!! I am sooo frustrated now!

>>I wrote another code for a file uploading windows script component (wsc -- see
>>http://www.4guysfromrolla.com/webtech/012401-1.shtml) It worked fine when it >>uploads file name to the database, but it won't let me to save an image to the >>image folder. It said something about the permission.

You said ...
>>You may need to get them to give write permissions for this folder.

How do I do that?
I have tested ASP page on the new server. It worked fine. When I wrote a code with using free ASP Simple Upload component, I got an error message saying "Server.CreateObject Failed" It obviously does not work on the new server for 3rd party components. Are you saying that the new server will work if using Persists or ASPUpload?? Not ASP Simple Upload??
You will have to talk directly to the host for that.  When doing a project like this it really pays to have a good relationship with a reliable hosting company.

Scratch that idea for the test ASP page...if it is loading the file name to the db then the problem is likely the permissions.  You want to get them to add WRITE permissions to that directory for IUSR_MACHINENAME.

I have to sign off now....Thunderstorms and severe weather...going out to look for tornado clouds!

Ciao until tomorrow.
Are you saying that the server should support asp file upload script? Will it work if I use Persists or ASPUpload? I think the server won't work with using ASP Simple Upload component.. Are Persists or ASPUpload free components? Can you give me the link for Persists or ASPUpload? I will test both of them on the server to see if either of them is working.
I used your code for Persists upload but modified it. It is still not working. All it says is "Server.CreateObject Failed " It points at Set Upload = Server.CreateObject("Persits.Upload.1")

The owner does not want CGI thing. Any ideas? Please help me. You are my only hope!
>>You want to get them to add WRITE permissions to that directory for IUSR_MACHINENAME.
Can you give me the code for that?
If it says CreateObject failed then Persists is not installed on their server....they must have another component.

You really need to touch base with the hosting company and find out exactly what component they support for uploading...otherwise you will spend your whole week guessing!

I cannot give you the code the change to write permissions on the server.....THEY need to do that for you.
How's it going today??
The owner already talked with the host. They said that they don't have an upload component, but they will put one on the server for her. And, they are going to do ASPUPLOAD by 12:00 tomorrow. That's great news for me and her!! WHEW!!
Hurray!  Are these guys new to the business???

Anyway, glad you got what you want...now you can use your script and the problem will be solved!
ASPUpload is installed in the server, but the system adm disabled the save method, so I have to use SaveVirtual feature! I want you to check the site (gave you the link in the email) /uploadform.asp. I created a new folder called photo.

Upload.SaveVirtual ("/photo/")

I got
Persits.Upload.1 error '800a0005'

Access is denied.

/newphoto.asp, line 11

Look like they need to give the write permissions for this folder..??
Here is the code I wrote:

<%

Set Upload = Server.CreateObject("Persits.Upload.1")

Set cn = Server.CreateObject("ADODB.Connection")
strConn =  "Driver={Microsoft Access Driver (*.mdb)}; " & _
          "DBQ=" & Server.Mappath ("/fpdb/Members.mdb")
cn.Open strConn
 
  Upload.SaveVirtual ("/photo/")
   
  addSQL = "INSERT INTO Contacts (MemberPhoto) VALUES ('" & File.ExtractFileName & "')"
  cn.execute addSQL
 
%>

<HTML>
<HEAD>
<TITLE>Photo Example</TITLE>
</HEAD>
<BODY>
This is my photo file example.
<%

If not (rs.BOF And rs.EOF) Then
if IsNull(rs("MemberPhoto")) then
 Response.Write "No picture"
else
%>
<img src="/photo/<%=rs("MemberPhoto")%>">
<% end if

end if
rs.Close
Set rs = nothing
%>
</BODY>
</HTML>
Yup...it's permissions.  They need to give you write permissions to that folder.
I want your opinion... What do you think if I insert the photo object into the database, not the file name of the image? Is it good idea? I have lots of problem with the server and have not gotten any email from the owner since yesterday afternoon! Thank you so much for your time with me.
VERY BAD IDEA.  Too much load on the server and takes up too much space in the db...it can also corrupt it.

I'd be worried about that hosting company if I were you.
Can you close the question now?
Sure.. Thanks for helping me.
Np...I hope you get everything straightened away.

I look forward to your next post....hopefully for something totally unrealated  ;-)

Cheers!
Classylinks: It works fine on the server! I created a smiple upload form with one file item.

But, I created a member page like this.

religion
occupation
interests/hobbies
...
...
...
photo (upload)


<form method="POST" ENCTYPE="multipart/form-data" action="mdb.asp">
<p><input type="text" name="Religion" size="20"><b><font face="Arial" size="2">Religion</font></b></p>
<p><input type="text" name="Occupation" size="20"><b><font face="Arial" size="2">Occupation</font></b></p>
<p><b><font face="Arial" size="2">Please describe your interest and/or hobbies below. Please use at least 100 characters and less than 250.</font></b></p>
<p><textarea rows="6" name="Interest" cols="41"></textarea></p>
<p><input type="file" name="UploadForm" size="30"><b><font face="Arial" size="2">Select a photo to upload</font></b></p>
<p><input type="submit" value="Submit" name="B1"><input type="reset" value="Reset" name="B2"></p>


mdb.asp
---------
strmreligion = Request.Form("Religion")
strmoccuptation = Request.Form("Occupation")
strminterest = Request.Form("Interest")

Dim oRsMember, Upload

Set oRsMember = Server.CreateObject("Adodb.Recordset")
Set Upload = Server.CreateObject("Persits.Upload.1")

Upload.Save "\photo\"

Set File = Upload.Files("UploadForm")

strCriteriaMember = "Select * FROM Contacts ORDER BY MemberID DESC"

oRsMember.Open strCriteriaMember, oConn, adOpenDynamic, adLockOptimistic, adCmdText

If not (oRsMember.BOF And oRsMember.EOF) then

oRsMember.AddNew
oRsMember("Religion") = strmreligion
oRsMember("Occupation") = strmoccupation
oRsMember("Interest") = strminterest
oRsMember("Timestamp") = now
oRsMember("MemberPhoto") = File.ExtractFileName
oRsMember.Update

End If

oRsMember.Close
Set oRsMember = Nothing


I got an error saying "Request.BinaryRead failed."
How can I fix it?

I will post a new question for you -- 50 points.

I am going to go ahead to post a question in ASP topic..

The error points to the line -- Upload.Save "\photo\"
The error points to the line -- Upload.Save "\photo\"