Solved

insert image path into database using asp upload

Posted on 2006-11-07
1
552 Views
Last Modified: 2010-05-18
I'm trying to use persits asp upload to allow my users to insert a picture of themselves into a details page. I've managed to get the upload part to work but I don't know how to get the image path into the database so that I can insert it into the details page. Here is my code now. Can someone give me general idea of where to go from here.

form page<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>

<body>
<FORM METHOD="POST" ENCTYPE="multipart/form-data" ACTION="UploadScript1.asp">
File 1:<INPUT TYPE=FILE NAME="FILE1">
Description 1:<INPUT TYPE=TEXT NAME="DESCR1"><BR>
File 2:<INPUT TYPE=FILE NAME="FILE2">
Description 2:<INPUT TYPE=TEXT NAME="DESCR2"><BR>

<INPUT TYPE=SUBMIT VALUE="Upload!">

</FORM>
</body>
</html>



Upload script<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>

<body>
<%  
Set Upload = Server.CreateObject("Persits.Upload.1")
Upload.SetMaxSize 10000, True
Upload.OverwriteFiles = False
Upload.Save "c:\upload"
%>  
Files:<BR>  
<%  
For Each File in Upload.Files  
Response.Write File.Name & "=" & File.Path & " (" & File.Size & ")<BR>"
Next
%>  
<P>  
Other items:<BR>  
<%  
For Each Item in Upload.Form  
Response.Write Item.Name & "=" & Item.Value & "<BR>"
Next
%>

</body>
</html>
0
Comment
Question by:elliottbenzle
1 Comment
 
LVL 25

Accepted Solution

by:
Rouchie earned 500 total points
ID: 17888164
Ahh lovely, another ASP question (**wink to Jason...!)

The problem is that Persist has been configured to upload the image to the directory "C:\upload" which is no good because that directory doesn't exist for the user - only on the server.

So, what you need to do is:

  1.  Decide on a directory that can be accessed by the browser, something like "uploads/images"

  2.  Configure the upload tool to use this directory using the mapPath command (which turns the above directory into "C:\...\uploads\images"
       Change:
             Upload.Save "c:\upload"
       to read:
             Upload.Save Server.MapPath("uploads/images")

  3.  You then add the file name to the end of the original directory path and save it to the database
       <%
       Dim fullFileName
       fullFileName = "uploads/images/" & File.Name
       %>
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

I still run into .cgi files every now and then. In some instances, I actually prefer the simplicity of a .cgi script to other options. Since I use DreamWeaver extensively, what I needed was a way to open .cgi scripts in Dreamweaver. And I wanted to …
This article is very specific and is only intended to help if you are installing Dreamweaver 8 in a Windows 7 environment with Office 2007 installed.   I'm not sure why Microsoft tends to release OS' that should not be released but they do.  Windows…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now