uploading pictures to a mysql database via coldfusion

i am trying to create an upload function that will allow a user to upl

Page 1 of 1

2 Replies - 4936 Views - Last Post: 23 January 2008 - 03:07 PM Rate Topic: -----

#1 cumupkid  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 63
  • Joined: 22-January 08

uploading pictures to a mysql database via coldfusion

Post icon  Posted 22 January 2008 - 09:44 AM

<cfparam name="PageNum_rsPhoto" default="1">
<cfset CurrentPage=GetFileFromPath(GetBaseTemplatePath())>
<cfquery name="rsPhoto" datasource="intheworksphotoco">
SELECT photos.PHOTONAME, photos.LARGEIMAGE, photos.DISCRIPTION
FROM photos
ORDER BY photos.PHOTOID
</cfquery>
<cfset MaxRows_rsPhoto=1>
<cfset StartRow_rsPhoto=Min((PageNum_rsPhoto-1)*MaxRows_rsPhoto+1,Max(rsPhoto.RecordCount,1))>
<cfset EndRow_rsPhoto=Min(StartRow_rsPhoto+MaxRows_rsPhoto-1,rsPhoto.RecordCount)>
<cfset TotalPages_rsPhoto=Ceiling(rsPhoto.RecordCount/MaxRows_rsPhoto)>
<cfset QueryString_rsPhoto=Iif(CGI.QUERY_STRING NEQ "",DE("&"&XMLFormat(CGI.QUERY_STRING)),DE(""))>
<cfset tempPos=ListContainsNoCase(QueryString_rsPhoto,"PageNum_rsPhoto=","&")>
<cfif tempPos NEQ 0>
<cfset QueryString_rsPhoto=ListDeleteAt(QueryString_rsPhoto,tempPos,"&")>
</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>Photo Gallery</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" href="../assets/intheworks.css" type="text/css" />
<script src="../Scripts/AC_RunActiveContent.js" type="text/javascript"></script>
</head>

<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr bgcolor="02021e">
<td colspan="4" rowspan="2" nowrap="nowrap"><img src="../assets/intheworks_pg_ban.jpg" alt="Header image" width="400" height="140" border="0" /></td>
<td height="58" nowrap="nowrap" colspan="4" id="logo" valign="bottom">In The Works Photo Co.</td>
</tr>
<tr bgcolor="02021E">
<td height="57" nowrap="nowrap" colspan="4" id="tagline" valign="top">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="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>
<tr>
<td height="40"><a href="../login/index.cfm">login</a></td>
</tr>
</table>
<br /></td>
<td width="2" bgcolor="#445DA0"><img src="../assets/intheworks_spacer.gif" alt="" width="1" height="1" border="0" /></td>
<th height="41" colspan="5" align="left" valign="top" nowrap="nowrap" class="pageName"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="37" class="pageName">Photo Gallery</td>
</tr>
</table>
<br />
<cfoutput query="rsPhoto" startrow="#StartRow_rsPhoto#" maxrows="#MaxRows_rsPhoto#">
<table width="600" height="98" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="25" class="subHeader">&nbsp;</td>
<td width="575" height="36" class="subHeader">#rsPhoto.PHOTONAME# </td>
</tr>
<tr>
<td height="31" colspan="2" align="center" class="bodyText"><img src="../images/#rsPhoto.LARGEIMAGE#" width="550" height="250" /></td>
</tr>
<tr>
<td height="31" colspan="2" class="bodyText"><div align="left" class="bodyText">
<div align="center">#rsPhoto.DISCRIPTION#</div>
</div></td>
</tr>
</table>
<table width="600" border="0" align="center" cellpadding="0" cellspacing="0" class="pictscan">
<tr>
<td width="120" align="center"><a href="#CurrentPage#?PageNum_rsPhoto=1#QueryString_rsPhoto#">First


</a></td>
<td width="120" align="center"><a href="#CurrentPage#?PageNum_rsPhoto=#Max(DecrementValue(PageNum_rsPhoto),1)##QueryString_rsPhoto#">Previous</a></td>
<td width="120" align="center">#StartRow_rsPhoto# Of #rsPhoto.RecordCount#</td>
<td width="120" align="center"><a href="#CurrentPage#?PageNum_rsPhoto=#Min(IncrementValue(PageNum_rsPhoto),TotalPages_rsPhoto)##QueryString_rsPhoto#">Next</a></td>
<td width="120" align="center"><a href="#CurrentPage#?PageNum_rsPhoto=#TotalPages_rsPhoto##QueryString_rsPhoto#">Last</a></td>
</tr>
</table>
<br />
</cfoutput>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><div align="center">This site designed &amp; maintained by <a href="mailto:jstickel56@gmail.com">Joseph Stickel</a></div></td>
</tr>
</table>
</th>
<td width="207" valign="top"><table width="200" border="0" align="right" cellpadding="0" cellspacing="0">
<tr>
<td colspan="3" id="sidebarHeader" class="sidebarHeader" align="center">Side notes and/or latest info</td>
</tr>
<tr>
<td width="45"><img src="../assets/intheworks_spacer.gif" alt="" width="40" height="1" border="0" /></td>
<td width="110" id="sidebar" class="smallText">
<p><img src="" alt="Picture place holder" name="picture" width="110" height="110" id="picture" style="background-color: #99CCFF" /><br />
Discription<br />
<a href="java script:;">read more &gt;</a></p>
<p><img src="" alt="Picture place holder" name="picture" width="110" height="110" id="picture2" style="background-color: #99CCFF" /><br />
Discription<br />
<a href="java script:;">read more &gt;</a></p> <p>&nbsp;</p></td>
<td width="45">&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td id="sidebar2" class="smallText">&nbsp;</td>
<td>&nbsp;</td>
</tr>
</table></td>
</tr>
<tr>
<td width="160">&nbsp;</td>
<td width="2"></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>
</table>
</html>

Is This A Good Question/Topic? 0
  • +

Replies To: uploading pictures to a mysql database via coldfusion

#2 dswens  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 34
  • Joined: 16-October 07

Re: uploading pictures to a mysql database via coldfusion

Posted 23 January 2008 - 01:19 PM

So what's your question?

We're not going to go on a wild goose chase through your code to see if there's an error.

If it is producing an error- the Error text would be nice.
If it's not, what's happening?
Was This Post Helpful? 0
  • +
  • -

#3 cumupkid  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 63
  • Joined: 22-January 08

Re: uploading pictures to a mysql database via coldfusion

Posted 23 January 2008 - 03:07 PM

So I figured out how to create an uplod form using coldfusion and dreamweaver 8 but...

1) i can not get a .jpg file to upload, but can get a .gif file to upload. Maybe it has something to do with the file size.

2) I need to be able to add the photo information to Mysql at the same time I upload the file.

Any help would be appreciated, I am including the code i have.

<!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">
<link href="../assets/intheworks.css" rel="stylesheet" type="text/css" />
<body>
<cfif isdefined ("form.upload_now")>

<cffile accept="image/gif, image/jpg" action="upload" destination="C:\ColdFusion8\wwwroot\intheworksphotoco\images\" filefield="ul_path" nameconflict="makeunique">
</cfif>
<!-- InstanceBegin template="/Templates/maintemplate.dwt" codeOutsideHTMLIsLocked="false" -->
<!-- DW6 -->
<head>
<!-- Copyright 2005 Macromedia, Inc. All rights reserved. -->
<!-- InstanceBeginEditable name="doctitle" -->
<title>Insert New Photo</title>
<!-- InstanceEndEditable -->
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" href="assets/intheworks.css" type="text/css" />
<!-- InstanceBeginEditable name="head" --><!-- InstanceEndEditable -->
</head>

<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>
<tr>
<td height="40"><a href="login/index.cfm">login</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"><!-- InstanceBeginEditable name="Page Content" -->
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td height="40" class="pageName">Insert New Photo</td>
</tr>
</table>
<br />
<table width="600" border="0" align="center" cellpadding="0" cellspacing="0" class="subHeader">
<tr>
<td height="35" class="subHeader">Content Title Here</td>
</tr>
</table>
<table width="600" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td><cfform action="index.cfm" method="post" enctype="multipart/form-data" name="upload_form" id="upload_form">
<cfinput type="file" name="ul_path" id="ul_path">
<cfinput type="submit" name="upload_now" id="upload_now" value="Upload">
</cfform>
</td>
</tr>
</table>
<!-- InstanceEndEditable --></th>
<td width="207" valign="top"><table width="200" border="0" align="right" cellpadding="0" cellspacing="0">
<tr>
<td colspan="3" id="sidebarHeader" class="sidebarHeader" align="center"><!-- InstanceBeginEditable name="Sidebar Heading" -->Side notes and/or latest info<!-- InstanceEndEditable --></td>
</tr>
<tr>
<td width="45"><img src="assets/intheworks_spacer.gif" alt="" width="40" height="1" border="0" /></td>
<td width="110" id="sidebar" class="smallText"><!-- InstanceBeginEditable name="Sidebar Content" -->
<p><img src="" alt="Picture place holder" name="picture" width="110" height="110" id="picture" style="background-color: #99CCFF" /><br />
Discription<br />
<a href="java script:;">read more &gt;</a></p>
<p><img src="" alt="Picture place holder" name="picture" width="110" height="110" id="picture2" style="background-color: #99CCFF" /><br />
Discription<br />
<a href="java script:;">read more &gt;</a></p>
<p>&nbsp;</p>
<!-- InstanceEndEditable --></td>
<td width="45">&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td id="sidebar2" class="smallText">&nbsp;</td>
<td>&nbsp;</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>
<!-- InstanceEnd --></body></html>
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1