473,563 Members | 2,292 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Uploadin Photos and photo info to mysql

1 New Member
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
1 3596
acoder
16,027 Recognized Expert Moderator MVP
Welcome to TSDN!

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

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

Similar topics

6
4459
by: Ralph Freshour | last post by:
I'm trying to code the ability for my users to upload up to photo's to mysql database - can someone point me in the right direction as to how this might be done in php? Perhaps a tutorial or some code samples? My two php books don't cover uploading photo's to a web site. Thanks...
7
3246
by: Eric Lindsay | last post by:
I would like to do a photo gallery with a liquid layout. I wanted to center a caption below each photo (or above each photo). I can do that easily with tables, but then I don't have a liquid layout. Besides, I wanted to try to do it with CSS. I can do centered captions with text-align. This works provided the element containing each...
0
1072
by: haa1973 | last post by:
0also photos http://www.0alsoufia.jeeran.com http://0alsoufia.jeeran.com/photo.html http://0alsoufia.jeeran.com/photo.html http://www.0alsoufia.jeeran.com 6309 http://www..com http://0alsoufia.jeeran.com/photo.html http://0alsoufia.jeeran.com/photo.html
10
2261
by: K. | last post by:
Hello all! I have a question to you. I would like to create photo gallery. I wonder if I should store photos (uploaded by users) in database $data = file_get_contents($_FILES); $data = mysql_real_escape_string($data);
4
3916
by: lorirobn | last post by:
Hi, I need to add photos to my database. Back End is on MS SQL Server (I believe 2000), and Front End is on MS Access. I have read about storing the photos as BLOBS, but I am not sure how to do this with SQL Server. Does this mean store the photo as OLE image, but do something else to it to make it a "Blob"? I have also read about...
11
2898
by: luftikus143 | last post by:
Hi there, I have a nice collection of photos on my photoblog, for which I created as well an archive, which shows the last 50 or so photos at the same time. Now, I would like to have the photos displayed all in the same size (although they are originally in different sizes, some cropped, some landscape, some portrait). Is it possible...
2
1295
by: Bhujanga | last post by:
I have a parent table - we'll call it SignOwners. It has various info about a bunch of sign owners. I have a child table that contains information about each sign these people own. Among that information is a filename that contains a photo of the subject sign. Now I want to put out a report that is organized by Owners and has a detail of each...
1
2577
by: davidson1 | last post by:
Hello friends, I have to load Photos in internet so that it should be seen by friends by using URL.Do u know any website ,so that we can load photos(many photos) collectively.Suppose for example tour photo = 24 College Photo = 24 Home Photo =22 3 division,inside each photos must be loaded
22
4015
by: skysober | last post by:
I have read and read about mysql, which I am sure is just like the quoted, "linux is very friendy, but it just chooses who it wants to be friends with..." My first attempt to read the database in my forum actually works! Well, almost. It does query the correct places, lists the information, and I have even figured out how to see a full path...
0
7579
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7877
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7631
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7943
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6238
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5479
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3631
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3615
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1194
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.