Solved

insert image path into database using asp upload

Posted on 2006-11-07
1
567 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…

724 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