By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
428,586 Members | 623 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 428,586 IT Pros & Developers. It's quick & easy.

Uploadin Photos and photo info to mysql

P: 1
II am trying to create a form that will allow me to upload photos to a folder in the site root directory and add the information to the mysql db at the same time.

I have created two forms, one that uploads to photo to the folder in the site root diorectory. One that uploads the info to mysql database. but...
When I try to upload them both ways at the same time i cant get it.

I am Including code for both pages i have working.

Code for upload photo:

Expand|Select|Wrap|Line Numbers
  1. <cflock scope="Session" type="ReadOnly" timeout="30" throwontimeout="no">
  2.   <cfset MM_Username=Iif(IsDefined("Session.MM_Username"), "Session.MM_Username",DE(""))>
  3.   <cfset MM_UserAuthorization=Iif(IsDefined("Session.MM_UserAuthorization"), "Session.MM_UserAuthorization",DE(""))>
  4. </cflock>
  5. <cfif MM_Username EQ "">
  6.   <cfset MM_referer=CGI.SCRIPT_NAME>
  7.   <cfif CGI.QUERY_STRING NEQ "">
  8.     <cfset MM_referer=MM_referer & "?" & CGI.QUERY_STRING>
  9.   </cfif>
  10.   <cfset MM_failureURL="login.cfm?accessdenied=" & URLEncodedFormat(MM_referer)>
  11.   <cflocation url="#MM_failureURL#" addtoken="no">
  12. </cfif>
  13.  
Expand|Select|Wrap|Line Numbers
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <link href="../assets/intheworks.css" rel="stylesheet" type="text/css" />
  4. <body>
Expand|Select|Wrap|Line Numbers
  1. <cfif isdefined ("form.upload_now")>
  2. <cffile accept="image/jpg,image/jpeg,image/pjpeg" action="upload" destination="C:\ColdFusion8\wwwroot\intheworksphotoco\images\" filefield="ul_path" nameconflict="makeunique">
  3.  
  4. </cfif>

Expand|Select|Wrap|Line Numbers
  1. <!-- InstanceBegin template="/Templates/maintemplate.dwt" codeOutsideHTMLIsLocked="false" -->
  2. <!-- DW6 -->
  3. <head>
  4. <!-- Copyright 2005 Macromedia, Inc. All rights reserved. -->
  5. <!-- InstanceBeginEditable name="doctitle" -->
  6. <title>Insert New Photo</title>
  7. <!-- InstanceEndEditable -->
  8. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  9. <link rel="stylesheet" href="../uploadphoto/assets/intheworks.css" type="text/css" />
  10. <!-- InstanceBeginEditable name="head" --><!-- InstanceEndEditable -->
  11. </head>
  12.  
  13. <table width="100%" border="0" cellspacing="0" cellpadding="0">
  14. <tr bgcolor="02021e">
  15. <td colspan="4" rowspan="2" nowrap="nowrap" bgcolor="#02021E"><img src="http://bytes.com/topic/coldfusion/assets/intheworks_pg_ban.jpg" alt="Header image" width="400" height="140" border="0" /></td>
  16. <td height="58" colspan="4" valign="bottom" nowrap="nowrap" bgcolor="#02021E" id="logo">In The Works Photo Co.</td>
  17. </tr>
  18. <tr bgcolor="02021E">
  19. <td height="57" colspan="4" valign="top" nowrap="nowrap" bgcolor="#02021E" id="tagline">Photos By Independent Photographer Jermey Wilson</td>
  20. </tr>
  21. <tr>
  22. <td colspan="8" bgcolor="#cc3300"><img src="http://bytes.com/topic/coldfusion/uploadphoto/assets/intheworks_spacer.gif" alt="" width="1" height="2" border="0" /></td>
  23. </tr>
  24.  
  25. <tr>
  26. <td colspan="8"><img src="http://bytes.com/topic/coldfusion/uploadphoto/assets/intheworks_spacer.gif" alt="" width="1" height="2" border="0" /></td>
  27. </tr>
  28.  
  29. <tr>
  30. <td colspan="8" bgcolor="#cc3300"><img src="http://bytes.com/topic/coldfusion/uploadphoto/assets/intheworks_spacer.gif" alt="" width="1" height="1" border="0" /></td>
  31. </tr>
  32.  
  33. <tr>
  34. <td colspan="8">&nbsp;&nbsp;<br /> </td>
  35. </tr>
  36. <tr>
  37. <td width="160" valign="top" height="370"><table border="0" cellspacing="0" cellpadding="0" width="155" id="navigation">
  38.   <tr>
  39.     <td width="155" height="40"><a href="http://bytes.com/topic/coldfusion/index.html">Home</a></td>
  40.   </tr>
  41.   <tr>
  42.     <td width="155" height="40"><a href="http://bytes.com/topic/coldfusion/photogallery/index.cfm">photo gallery</a></td>
  43.   </tr>
  44.   <tr>
  45.     <td width="155" height="40"><a href="http://bytes.com/topic/coldfusion/aboutme/index.html">about me</a></td>
  46.   </tr>
  47.   <tr>
  48.     <td width="155" height="40"><a href="http://bytes.com/topic/coldfusion/contactme/index.html">contact me</a></td>
  49.   </tr>
  50. </table>
  51.   <br /></td>
  52. <td width="2" rowspan="2" bgcolor="#445DA0"><img src="http://bytes.com/topic/coldfusion/uploadphoto/assets/intheworks_spacer.gif" alt="" width="1" height="1" border="0" /></td>
  53. <th height="370" colspan="5" align="left" valign="top"><!-- InstanceBeginEditable name="Page Content" -->
  54. <table width="100%" border="0" cellpadding="0" cellspacing="0">
  55. <tr>
  56. <td height="40" class="pageName">Insert New Photo</td>
  57. </tr>
  58. </table>
  59. <br />
  60. <table width="600" border="0" align="center" cellpadding="0" cellspacing="0" class="subHeader">
  61. <tr>
  62. <td height="40" class="subHeader">Photo To Upload</td>
  63. </tr>
  64. </table>
  65. <table width="600" border="0" align="center" cellpadding="0" cellspacing="0">
  66. <tr>
  67.   <td height="40"><form action="insertphoto_to_file.cfm" method="post" enctype="multipart/form-data" name="upload_form" id="upload_form">
  68.     <table width="600" border="0" cellspacing="0" cellpadding="0">
  69.       <tr>
  70.         <td height="40">&nbsp;</td>
  71.         <td height="40">&nbsp;</td>
  72.       </tr>
  73.       <tr>
  74.         <td height="40">&nbsp;</td>
  75.         <td height="40">&nbsp;</td>
  76.       </tr>
  77.       <tr>
  78.         <td height="40" colspan="2" align="center"><input type="file" name="ul_path" id="ul_path" /></td>
  79.         </tr>
  80.       <tr>
  81.         <td width="300" height="40">&nbsp;</td>
  82.         <td width="300" height="40"><input type="submit" name="upload_now" id="upload_now" value="Upload" /></td>
  83.       </tr>
  84.     </table>
  85.     </form>
  86.   </td>
  87. </tr>
  88. </table>
  89. <!-- InstanceEndEditable --></th>
  90. <td width="207" valign="top"><table width="155" border="0" align="right" cellpadding="0" cellspacing="0" id="navigation2">
  91.   <tr>
  92.     <td width="155" height="40"><a href="index.cfm">Admin Home</a></td>
  93.   </tr>
  94.   <tr>
  95.     <td width="155" height="40"><a href="masterphoto_list.cfm"> Photo Info List</a></td>
  96.   </tr>
  97.   <tr>
  98.     <td width="155" height="40"><a href="insertphoto_to_file.cfm">Upload Photo</a></td>
  99.   </tr>
  100.   <tr>
  101.     <td height="40"><a href="insertphoto_to_mysql.cfm">Insert Photo Info</a></td>
  102.   </tr>
  103.   <tr>
  104.     <td height="40"><a href="logout.cfm">logout</a></td>
  105.   </tr>
  106. </table></td>
  107. </tr>
  108. <tr>
  109. <td width="160"><p><br />
  110. </p></td>
  111. <td width="152">&nbsp;</td>
  112. <td width="87">&nbsp;</td>
  113. <td width="413">&nbsp;</td>
  114. <td width="48">&nbsp;</td>
  115. <td width="196">&nbsp;</td>
  116. <td width="207">&nbsp;</td>
  117. </tr>
  118. <tr>
  119. <td>&nbsp;</td>
  120. <td bgcolor="#445DA0">&nbsp;</td>
  121. <td height="10" colspan="5" align="center">This site designed &amp; maintained by <a href="mailto:****@gmail.com">Joseph Stickel</a></td>
  122. <td>&nbsp;</td>
  123. </tr>
  124. </table>
  125. <!-- InstanceEnd --></body></html>
  126.  


Code for photo info to mysql:

Expand|Select|Wrap|Line Numbers
  1. <cflock scope="Session" type="ReadOnly" timeout="30" throwontimeout="no">
  2.   <cfset MM_Username=Iif(IsDefined("Session.MM_Username"), "Session.MM_Username",DE(""))>
  3.   <cfset MM_UserAuthorization=Iif(IsDefined("Session.MM_UserAuthorization"), "Session.MM_UserAuthorization",DE(""))>
  4. </cflock>
  5. <cfif MM_Username EQ "">
  6.   <cfset MM_referer=CGI.SCRIPT_NAME>
  7.   <cfif CGI.QUERY_STRING NEQ "">
  8.     <cfset MM_referer=MM_referer & "?" & CGI.QUERY_STRING>
  9.   </cfif>
  10.   <cfset MM_failureURL="login.cfm?accessdenied=" & URLEncodedFormat(MM_referer)>
  11.   <cflocation url="#MM_failureURL#" addtoken="no">
  12. </cfif>
  13. <cfset CurrentPage=GetFileFromPath(GetBaseTemplatePath())>
  14. <cfif IsDefined("FORM.MM_InsertRecord") AND FORM.MM_InsertRecord EQ "upload_to_mysql">
  15.   <cfquery datasource="intheworksphotoco">   
  16.     INSERT INTO photos (PHOTONAME, LARGEIMAGE, DISCRIPTION)
  17. VALUES (<cfif IsDefined("FORM.photoname") AND #FORM.photoname# NEQ "">
  18. <cfqueryparam value="#FORM.photoname#" cfsqltype="cf_sql_clob" maxlength="50">
  19. <cfelse>
  20. ''
  21. </cfif>
  22. , <cfif IsDefined("FORM.largeimage") AND #FORM.largeimage# NEQ "">
  23. <cfqueryparam value="#FORM.largeimage#" cfsqltype="cf_sql_clob" maxlength="30">
  24. <cfelse>
  25. ''
  26. </cfif>
  27. , <cfif IsDefined("FORM.discription") AND #FORM.discription# NEQ "">
  28. <cfqueryparam value="#FORM.discription#" cfsqltype="cf_sql_clob" maxlength="2147483647">
  29. <cfelse>
  30. ''
  31. </cfif>
  32. )
  33.   </cfquery>
  34.   <cflocation url="masterphoto_list.cfm">
  35. </cfif>
  36.  
Expand|Select|Wrap|Line Numbers
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <!-- DW6 -->
  4. <head>
  5. <!-- Copyright 2005 Macromedia, Inc. All rights reserved. -->
  6.  
  7. <title>Upload Photo Info</title>
  8.  
  9. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  10. <link rel="stylesheet" href="../assets/intheworks.css" type="text/css" />
  11. </head>
  12. <body>
  13.  
  14. <table width="100%" border="0" cellspacing="0" cellpadding="0">
  15.   <tr bgcolor="02021e">
  16.     <td colspan="4" rowspan="2" nowrap="nowrap" bgcolor="#02021E"><img src="http://bytes.com/topic/coldfusion/assets/intheworks_pg_ban.jpg" alt="Header image" width="400" height="140" border="0" /></td>
  17.     <td height="58" colspan="4" valign="bottom" nowrap="nowrap" bgcolor="#02021E" id="logo">In The Works Photo Co.</td>
  18.   </tr>
  19.   <tr bgcolor="02021E">
  20.     <td height="57" colspan="4" valign="top" nowrap="nowrap" bgcolor="#02021E" id="tagline">Photos By Independent Photographer Jermey Wilson</td>
  21.   </tr>
  22.   <tr>
  23.     <td colspan="8" bgcolor="#cc3300"><img src="http://bytes.com/topic/coldfusion/assets/intheworks_spacer.gif" alt="" width="1" height="2" border="0" /></td>
  24.   </tr>
  25.  
  26.    <tr>
  27.     <td colspan="8"><img src="http://bytes.com/topic/coldfusion/assets/intheworks_spacer.gif" alt="" width="1" height="2" border="0" /></td>
  28.   </tr>
  29.  
  30.    <tr>
  31.     <td colspan="8" bgcolor="#cc3300"><img src="http://bytes.com/topic/coldfusion/assets/intheworks_spacer.gif" alt="" width="1" height="1" border="0" /></td>
  32.   </tr>
  33.  
  34.    <tr>
  35.     <td colspan="8">&nbsp;&nbsp;<br />    </td>
  36.   </tr>
  37.   <tr>
  38.     <td width="160" valign="top" height="370"><table border="0" cellspacing="0" cellpadding="0" width="155" id="navigation">
  39.       <tr>
  40.         <td width="155" height="40"><a href="http://bytes.com/topic/coldfusion/index.html">Home</a></td>
  41.       </tr>
  42.       <tr>
  43.         <td width="155" height="40"><a href="http://bytes.com/topic/coldfusion/photogallery/index.cfm">photo gallery</a></td>
  44.       </tr>
  45.       <tr>
  46.         <td width="155" height="40"><a href="http://bytes.com/topic/coldfusion/aboutme/index.html">about me</a></td>
  47.       </tr>
  48.       <tr>
  49.         <td width="155" height="40"><a href="http://bytes.com/topic/coldfusion/contactme/index.html">contact me</a></td>
  50.       </tr>
  51.     </table>
  52.     <br /></td>
  53.     <td width="2" rowspan="2" bgcolor="#445DA0"><img src="http://bytes.com/topic/coldfusion/assets/intheworks_spacer.gif" alt="" width="1" height="1" border="0" /></td>
  54.     <th height="370" colspan="5" align="left" valign="top">
  55.       <table width="100%" border="0" cellpadding="0" cellspacing="0">
  56.         <tr>
  57.           <td height="40" class="pageName">Upload Photo Information</td>
  58.         </tr>
  59.       </table>
  60.       <br />
  61.       <table width="600" border="0" align="center" cellpadding="0" cellspacing="0" class="subHeader">
  62.         <tr>
  63.           <td height="40" class="subHeader">Photo Information</td>
  64.         </tr>
  65.       </table>      <table width="600" border="0" align="center" cellpadding="0" cellspacing="0">
  66.         <tr>
  67.           <td><form action="<cfoutput>#CurrentPage#</cfoutput>" method="POST" enctype="multipart/form-data" name="upload_to_mysql" id="upload_to_mysql">
  68.             <table width="600" border="0">
  69.               <tr>
  70.                 <td width="150" height="40">Photo Name:</td>
  71.                 <td width="450" height="40"><input type="text" name="photoname" id="photoname" /></td>
  72.               </tr>
  73.               <tr>
  74.                 <td width="150" height="40">Phot File Name:</td>
  75.                 <td width="450" height="40"><input type="text" name="largeimage" id="largeimage" /></td>
  76.               </tr>
  77.               <tr>
  78.                 <td width="150" height="40"> Photo Discription:</td>
  79.                 <td width="450" height="40"><input type="text" name="discription" id="discription" /></td>
  80.               </tr>
  81.               <tr>
  82.                 <td height="40" align="center">&nbsp;</td>
  83.                 <td height="40" align="left"><input type="submit" name="submit" id="submit" value="Upload" />
  84.                   <input type="reset" name="reset" id="reset" value="Reset" /></td>
  85.               </tr>
  86.               <tr>
  87.                 <td height="40">&nbsp;</td>
  88.                 <td height="40">&nbsp;</td>
  89.               </tr>
  90.             </table>
  91.               <input type="hidden" name="MM_InsertRecord" value="upload_to_mysql" />
  92.           </form>          </td>
  93.         </tr>
  94.     </table></th>
  95.     <td width="207" valign="top"><table width="155" border="0" align="right" cellpadding="0" cellspacing="0" id="navigation2">
  96.       <tr>
  97.         <td width="155" height="40"><a href="index.cfm">Admin Home</a></td>
  98.       </tr>
  99.       <tr>
  100.         <td width="155" height="40"><a href="masterphoto_list.cfm"> Photo Info List</a></td>
  101.       </tr>
  102.       <tr>
  103.         <td width="155" height="40"><a href="insertphoto_to_file.cfm">Upload Photo</a></td>
  104.       </tr>
  105.       <tr>
  106.         <td height="40"><a href="insertphoto_to_mysql.cfm">Insert Photo Info</a></td>
  107.       </tr>
  108.       <tr>
  109.         <td height="40"><a href="logout.cfm">logout</a></td>
  110.       </tr>
  111.     </table></td>
  112.   </tr>
  113.   <tr>
  114.     <td width="160"><p><br />
  115.     </p></td>
  116.     <td width="152">&nbsp;</td>
  117.     <td width="87">&nbsp;</td>
  118.     <td width="413">&nbsp;</td>
  119.     <td width="48">&nbsp;</td>
  120.     <td width="196">&nbsp;</td>
  121.     <td width="207">&nbsp;</td>
  122.   </tr>
  123.   <tr>
  124.     <td>&nbsp;</td>
  125.     <td bgcolor="#445DA0">&nbsp;</td>
  126.     <td height="10" colspan="5" align="center">This site designed &amp; maintained by <a href="mailto:****@gmail.com">Joseph Stickel</a></td>
  127.     <td>&nbsp;</td>
  128.   </tr>
  129.   </table>
  130. </body>
  131. </html>
Jan 26 '08 #1
Share this Question
Share on Google+
1 Reply


acoder
Expert Mod 15k+
P: 16,027
Welcome to TSDN!

So, how have you combined the two?
Jan 28 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.