Welcome to Dream.In.Code
Getting Help is Easy!

Join 118,878 Programmers for FREE! Ask your question and get quick answers from experts. There are 1,965 online right now! We've got more than 500 tutorials and 2,000 snippets. Join and find out why Dream.In.Code is the #1 programming help community on the internet! Registration is fast and FREE... Join Now!



uploading database info and pictures at the same time

 
Reply to this topicStart new topic

uploading database info and pictures at the same time

cumupkid
post 25 Jan, 2008 - 10:53 PM
Post #1


New D.I.C Head

*
Joined: 22 Jan, 2008
Posts: 9

I am trying to make this form upload information about photos at the same time
as uploading a photo to a folder in my root.

I have 2 different pages, 1 that uploads the photo to the folder and one that uploads info to the mysql db.

when i put the 2 together only info to my sql works.


Code... Code in red is whhat I cant get to work.

<cflock scope="Session" type="ReadOnly" timeout="30" throwontimeout="no">
<cfset MM_Username=Iif(IsDefined("Session.MM_Username"),"Session.MM_Username",DE(""))>
<cfset MM_UserAuthorization=Iif(IsDefined("Session.MM_UserAuthorization"),"Session.MM_UserAuthorization",DE(""))>
</cflock>
<cfif MM_Username EQ "">
<cfset MM_referer=CGI.SCRIPT_NAME>
<cfif CGI.QUERY_STRING NEQ "">
<cfset MM_referer=MM_referer & "?" & CGI.QUERY_STRING>
</cfif>
<cfset MM_failureURL="login.cfm?accessdenied=" & URLEncodedFormat(MM_referer)>
<cflocation url="#MM_failureURL#" addtoken="no">
</cfif>
<cfset CurrentPage=GetFileFromPath(GetBaseTemplatePath())>
<cfif IsDefined("FORM.MM_InsertRecord") AND FORM.MM_InsertRecord EQ "upload_to_mysql">
<cfquery datasource="intheworksphotoco">
INSERT INTO photos (PHOTONAME, LARGEIMAGE, DISCRIPTION)
VALUES (<cfif IsDefined("FORM.photoname") AND #FORM.photoname# NEQ "">
<cfqueryparam value="#FORM.photoname#" cfsqltype="cf_sql_clob" maxlength="50">
<cfelse>
''
</cfif>
, <cfif IsDefined("FORM.largeimage") AND #FORM.largeimage# NEQ "">
<cfqueryparam value="#FORM.largeimage#" cfsqltype="cf_sql_clob" maxlength="30">
<cfelse>
''
</cfif>
, <cfif IsDefined("FORM.discription") AND #FORM.discription# NEQ "">
<cfqueryparam value="#FORM.discription#" cfsqltype="cf_sql_clob" maxlength="2147483647">
<cfelse>
''
</cfif>
)
</cfquery>
<cflocation url="masterphoto_list.cfm">
</cfif>
<!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">
<!-- DW6 -->
<head>
<!-- Copyright 2005 Macromedia, Inc. All rights reserved. -->

<title>Upload Photo Info</title>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" href="../assets/intheworks.css" type="text/css" />
</head>
<body>


<cfif isdefined ("form.upload_now")>
<cffile accept="image/jpg,image/jpeg,image/pjpeg" action="upload" destination="C:\ColdFusion8\wwwroot\intheworksphotoco\images\" filefield="ul_path" nameconflict="makeunique">

</cfif>

<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr bgcolor="02021e">
<td colspan="4" rowspan="2" nowrap="nowrap" bgcolor="#02021E"><img src="../assets/intheworks_pg_ban.jpg" alt="Header image" width="400" height="140" border="0" /></td>
<td height="58" colspan="4" valign="bottom" nowrap="nowrap" bgcolor="#02021E" id="logo">In The Works Photo Co.</td>
</tr>
<tr bgcolor="02021E">
<td height="57" colspan="4" valign="top" nowrap="nowrap" bgcolor="#02021E" id="tagline">Photos By Independent Photographer Jermey Wilson</td>
</tr>
<tr>
<td colspan="8" bgcolor="#cc3300"><img src="../assets/intheworks_spacer.gif" alt="" width="1" height="2" border="0" /></td>
</tr>

<tr>
<td colspan="8"><img src="../assets/intheworks_spacer.gif" alt="" width="1" height="2" border="0" /></td>
</tr>

<tr>
<td colspan="8" bgcolor="#cc3300"><img src="../assets/intheworks_spacer.gif" alt="" width="1" height="1" border="0" /></td>
</tr>

<tr>
<td colspan="8">&nbsp;&nbsp;<br /> </td>
</tr>
<tr>
<td width="160" valign="top" height="370"><table border="0" cellspacing="0" cellpadding="0" width="155" id="navigation">
<tr>
<td width="155" height="40"><a href="../index.html">Home</a></td>
</tr>
<tr>
<td width="155" height="40"><a href="../photogallery/index.cfm">photo gallery</a></td>
</tr>
<tr>
<td width="155" height="40"><a href="../aboutme/index.html">about me</a></td>
</tr>
<tr>
<td width="155" height="40"><a href="../contactme/index.html">contact me</a></td>
</tr>
</table>
<br /></td>
<td width="2" rowspan="2" bgcolor="#445DA0"><img src="../assets/intheworks_spacer.gif" alt="" width="1" height="1" border="0" /></td>
<th height="370" colspan="5" align="left" valign="top">
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td height="40" class="pageName">Upload Photo Information</td>
</tr>
</table>
<br />
<table width="600" border="0" align="center" cellpadding="0" cellspacing="0" class="subHeader">
<tr>
<td height="40" class="subHeader">Photo Information</td>
</tr>
</table> <table width="600" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td><form action="<cfoutput>#CurrentPage#</cfoutput>" method="POST" enctype="multipart/form-data" name="upload_to_mysql" id="upload_to_mysql">
<table width="600" border="0">
<tr>
<td width="150" height="40">Photo Name:</td>
<td width="450" height="40"><input type="text" name="photoname" id="photoname" /></td>
</tr>
<tr>
<td width="150" height="40">Phot File Name:</td>
<td width="450" height="40"><input type="text" name="largeimage" id="largeimage" /></td>
</tr>
<tr>
<td width="150" height="40"> Photo Discription:</td>
<td width="450" height="40"><input type="text" name="discription" id="discription" /></td>
</tr>
<tr>
<td height="40" align="center">&nbsp;</td>
<td height="40" align="left"><input type="file" name="ul_photo" id="ul_photo" /></td>
</tr>
<tr>
<td height="40">&nbsp;</td>
<td height="40"><input type="submit" name="submit" id="submit" value="Upload" />
<input type="reset" name="reset" id="reset" value="Reset" /></td>
</tr>
</table>
<input type="hidden" name="MM_InsertRecord" value="upload_to_mysql" />
</form> </td>
</tr>
</table></th>
<td width="207" valign="top"><table width="155" border="0" align="right" cellpadding="0" cellspacing="0" id="navigation2">
<tr>
<td width="155" height="40"><a href="index.cfm">Admin Home</a></td>
</tr>
<tr>
<td width="155" height="40"><a href="masterphoto_list.cfm"> Photo Info List</a></td>
</tr>
<tr>
<td width="155" height="40"><a href="insertphoto_to_file.cfm">Upload Photo</a></td>
</tr>
<tr>
<td height="40"><a href="insertphoto_to_mysql.cfm">Insert Photo Info</a></td>
</tr>
<tr>
<td height="40"><a href="logout.cfm">logout</a></td>
</tr>
</table></td>
</tr>
<tr>
<td width="160"><p><br />
</p></td>
<td width="152">&nbsp;</td>
<td width="87">&nbsp;</td>
<td width="413">&nbsp;</td>
<td width="48">&nbsp;</td>
<td width="196">&nbsp;</td>
<td width="207">&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td bgcolor="#445DA0">&nbsp;</td>
<td height="10" colspan="5" align="center">This site designed &amp; maintained by <a href="mailto:jstickel56@gmail.com">Joseph Stickel</a></td>
<td>&nbsp;</td>
</tr>
</table>
</body>
</html>
User is offlineProfile CardPM

Go to the top of the page


jerrittpace
post 15 Mar, 2008 - 12:36 AM
Post #2


New D.I.C Head

*
Joined: 15 Mar, 2008
Posts: 1

We were having this problem too for a second tonight... this was the only resource we found too.

Heres our code that work... youll have to create the table consumercars with all the column names we have here... but at least this is a great start

our action page was called added.cfm

<!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=utf-8" />
<title>Cool Car Uploaded</title>
<style type="text/css">
<!--
body,td,th {
color: #FFFFFF;
}
body {
background-color: #000000;
}
a:link {
color: #FFFFFF;
}
a:visited {
color: #FFFFFF;
}
a:active {
color: #FFFFFF;
}
a:hover {
color: #999999;
}
.style7 { font-size: 18px;
}
#apDiv4 { position:absolute;
width:395px;
height:68px;
z-index:3;
left: 476px;
top: 20px;
}
#apDiv { position:absolute;
width:395px;
height:68px;
z-index:3;
left: 476px;
top: 20px;
}
-->
</style>
<script src="Scripts/AC_RunActiveContent.js" type="text/javascript"></script>
</head>

<body>

<p>
<cfinsert datasource="userLogin1" dbtype="ODBC" tablename="consumercars" formfields="vehYear, vehMake, vehModel, vehVIN, vehMileage, vehPrice">
</p>
<div id="apDiv4">
<div align="right">
<p align="right"><a href="http://sellcoolcars.com/upload_photos/cf_upload.cfm" class="style7">photo upload </a> <a href="http://sellcoolcars.com/" class="style7"> HOME </a><a href="http://sellcoolcars.com/login/login.cfm" class="style7">Login </a><a href="http://sellcoolcars.com/SellCoolCars_contact.cfm" class="style7">Contact Us</a></p>
</div>
</div>
<div id="apDiv">
<div align="right">
<p align="right"><a href="http://sellcoolcars.com/upload_photos/cf_upload.cfm" class="style7">photo upload </a> <a href="http://sellcoolcars.com/" class="style7"> HOME </a><a href="http://sellcoolcars.com/login/login.cfm" class="style7">Login </a><a href="http://sellcoolcars.com/SellCoolCars_contact.cfm" class="style7">Contact Us</a></p>
</div>
</div>
<h1>&nbsp;</h1>
<p>&nbsp;</p>
<div align="center">
<p>
<script type="text/javascript">
AC_FL_RunContent( 'codebase','http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0','width','800','height','100','align','middle','title','Under Construction','src','1112','loop','false','quality','high','pluginspage','http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash','movie','1112' ); //end AC code
</script>
<noscript>
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0" width="800" height="100" align="middle" title="Under Construction">
<param name="movie" value="1112.swf" />
<param name="quality" value="high" />
<param name="LOOP" value="false" />
<embed src="1112.swf" width="800" height="100" loop="False" align="middle" quality="high" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash"></embed>
</object>
</noscript>
</p>
<p>
<script type="text/javascript">
AC_FL_RunContent( 'codebase','http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0','width','800','height','25','title','SELL YOUR COOL CARS','src','1123','quality','high','pluginspage','http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash','movie','1123' ); //end AC code
</script>
<noscript>
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0" width="800" height="25" title="SELL YOUR COOL CARS">
<param name="movie" value="1123.swf" />
<param name="quality" value="high" />
<embed src="1123.swf" quality="high" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="800" height="25"></embed>
</object>
</noscript>
<script type="text/javascript">
AC_FL_RunContent( 'codebase','http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0','width','800','height','20','title','SELL YOUR COOL CARS','src','test1123','quality','high','pluginspage','http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash','movie','test1123' ); //end AC code
</script>
<noscript>
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0" width="800" height="20" title="SELL YOUR COOL CARS">
<param name="movie" value="test1123.swf" />
<param name="quality" value="high" />
<embed src="test1123.swf" quality="high" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="800" height="20"></embed>
</object>
</noscript>
</p>
</div>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<cfif isdefined("FORM.upload_now")>
<cffile

accept="image/gif, image/jpeg"
action="upload"
destination="D:\home\sellcoolcars.com\wwwroot\upload_photos\photos" filefield="vehPhoto1" nameconflict="makeunique">
<cfoutput>
<h1>New Vehicle</h1>
#FORM.vehYear#, #FORM.vehMake#, #FORM.vehModel#
<h1>has been added</h1>
</cfoutput>
</cfif>
<p>&nbsp; </p>
</body>
</html>


and then this is our members_only



<!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=utf-8" />
<title>Members Only</title>
<style type="text/css">
<!--
body,td,th {
color: #FFFFFF;
}
body {
background-color: #000000;
}
a:link {
color: #FFFFFF;
}
a:visited {
color: #FFFFFF;
}
a:hover {
color: #999999;
}
a:active {
color: #FFFFFF;
}
.style7 { font-size: 18px;
}
#apDiv4 { position:absolute;
width:395px;
height:68px;
z-index:3;
left: 476px;
top: 20px;
}
-->
</style></head>

<body>

<p>
<!--- Upload Info/Photos --->
</p>
<div id="apDiv4">
<div align="right">
<p align="right"><a href="http://sellcoolcars.com/upload_photos/cf_upload.cfm" class="style7">photo upload </a> <a href="http://sellcoolcars.com/" class="style7"> HOME </a><a href="http://sellcoolcars.com/login/login.cfm" class="style7">Login </a><a href="http://sellcoolcars.com/SellCoolCars_contact.cfm" class="style7">Contact Us</a></p>
</div>
</div>
<p>&nbsp;</p>
<p>&nbsp;</p>
<form action="added.cfm" method="post" enctype="multipart/form-data" name="fileUpload" id="fileUpload">
<h1>Please enter your vehicle information and then click <strong>Upload</strong>. </h1>
<p>
<input type="integer" name="vehYear" />
Year:<br />
<input type="text" name="vehMake" />
Make:
<br />
<input type="text" name="vehModel" />
Model:
<br />
<input type="varChar" name="vehVIN" />
VIN:<br />
<input type="int" name="vehMileage" />
Mileage:<br />
<input type="int" name="vehPrice" />
Price:
<br />
</p>
<h3>Upload Photos of Your Cool Car</h3>
<table width="526" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="137">Upload an Image
<label></label></td>
<td width="374"><input type="file" name="vehPhoto1" id="file1" /></td>
</tr>
<tr>
<td width="137">Upload an Image
<label></label></td>
<td width="374"><input type="file" name="vehPhoto2" id="file2" /></td>
</tr>
<tr>
<td width="137">Upload an Image
<label></label></td>
<td width="374"><input type="file" name="vehPhoto3" id="file3" /></td>
</tr>
<tr>
<td width="137">Upload an Image
<label></label></td>
<td width="374"><input type="file" name="vehPhoto4" id="file4" /></td>
</tr>
<tr>
<td width="137">Upload an Image
<label></label></td>
<td width="374"><input type="file" name="vehPhoto5" id="file5" /></td>
</tr>
<tr>
<td width="137">Upload an Image
<label></label></td>
<td width="374"><input type="file" name="vehPhoto6" id="file6" /></td>
</tr>
<tr>
<td width="137">Upload an Image
<label></label></td>
<td width="374"><input type="file" name="vehPhoto7" id="file7" /></td>
</tr>
<tr>
<td width="137">Upload an Image
<label></label></td>
<td width="374"><input type="file" name="vehPhoto8" id="file8" /></td>
</tr>
<tr>
<td width="137">Upload an Image
<label></label></td>
<td width="374"><input type="file" name="vehPhoto9" id="file9" /></td>
</tr>
<tr>
<td width="137">Upload an Image
<label></label></td>
<td width="374"><input type="file" name="vehPhoto10" id="file10" /></td>
</tr>
</table>
<hr/>
<input name="upload_now" type="submit" id="upload_now" value="Sell Your Car" />
</form>
<p>&nbsp; </p>
</body>
</html>

oh i forgot youre gonna be missing the swf files... oh well you can see them and download them at sellcoolcars.com if you want

Peace

Jerritt

jerrittpace@yahoo.ie
User is offlineProfile CardPM

Go to the top of the page

Fast ReplyReply to this topicStart new topic
Time is now: 10/13/08 02:36AM

Live Help!

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month