ColdFusion Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreColdFusion Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now!
  #1  
Old March 1st, 2005, 07:52 PM
perlnewbie23 perlnewbie23 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2004
Posts: 105 perlnewbie23 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 41 sec
Reputation Power: 4
Help:Uploading an image and saving it in db.

Hi, I'm trying to upload an image from my webpage that i'm creating and inserting it into my database in access. But i'm having an error message that said: "Invalid data C:\CFusionMX7\runtime\servers\coldfusion\SERVER-INF\temp\wwwroot-tmp\neotmp20871.tmp,Upload for CFSQLTYPE CF_SQL_LONGBINARY."

Here is my code:
PHP Code:
<!--Insert a new product into the shoe table-->
<
cflock name="InsertNewProduct" type="exclusive" timeout="30">
<
cftransaction>
<
cfquery name="AddProduct" datasource="shoes">
    
INSERT INTO shoe(manufactorIDbrandnamedetailstypepricecolorsize)
    
VALUES('#form.manufactorID#''#form.brand#''#form.name#''#form.details#''#form.type#'
    
'#form.price#','#form.color#''#form.size#')
</
cfquery>
<!--
This query retrieves the primary key value of the product we just inserted-->
<
cfquery name="GetPK" datasource="shoes">
    
SELECT MAX(shoeID) AS MaxShoeID FROM Shoe
</cfquery>
</
cftransaction>
</
cflock>

<!--
This query uses the value returned by the GetPK query to lookup the full product we inserted-->
<
cfquery name="GetProduct" datasource="shoes">
    
SELECT shoeIDmanufactorIDbrandnamedetailstypepriceimageURLcolorsize FROM shoe
    WHERE shoeID 
#GetPK.MaxShoeID#
</cfquery>

<!---
file upload--->
<
cfif isdefined("form.imageURL")>
<
cffile action="Upload"
filefield="imageURL"
destination="C:\Inetpub\wwwroot\soleshop"
nameconflict="makeunique"
accept="image/*">
<
cfset upload_file#file.serverfile#>
<cfoutput>#serverFile# successfully added. Size of the upload file:
#Numberformat(Evaluate(File.FileSize/1024))# KB. 
</cfoutput>
</
cfif>
<
cfinsert datasource="shoes"
tablename ="shoe"
formfields="imageURL">

<!
DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<
html>
</
html


Please help. Thanks!

Reply With Quote
  #2  
Old March 1st, 2005, 08:32 PM
kiteless kiteless is offline
Moderator
Dev Shed Expert (3500 - 3999 posts)
 
Join Date: Jun 2002
Location: Raleigh, NC
Posts: 3,627 kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Week 4 Days 10 h 8 m 55 sec
Reputation Power: 53
Not sure about the error, but I strongly recommend NOT storing the image in the database. Store the image on the hard drive and store the PATH to the image in the database. CLOBS and BLOBS are always a real pain to work with, each driver and each database deal with them differently. Save yourself a lot of pain.
__________________
Ask if you have a question, but also help answer questions that you have knowledge of! Thanks, Brian.
How to Post a Question in the Forums

Reply With Quote
  #3  
Old March 1st, 2005, 08:35 PM
perlnewbie23 perlnewbie23 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2004
Posts: 105 perlnewbie23 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 41 sec
Reputation Power: 4
Quote:
Originally Posted by kiteless
Not sure about the error, but I strongly recommend NOT storing the image in the database. Store the image on the hard drive and store the PATH to the image in the database. CLOBS and BLOBS are always a real pain to work with, each driver and each database deal with them differently. Save yourself a lot of pain.


How do I store the image path into the database?

Reply With Quote
  #4  
Old March 2nd, 2005, 07:54 AM
kiteless kiteless is offline
Moderator
Dev Shed Expert (3500 - 3999 posts)
 
Join Date: Jun 2002
Location: Raleigh, NC
Posts: 3,627 kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Week 4 Days 10 h 8 m 55 sec
Reputation Power: 53
As a string. So if you put the image at "c:/inetput/wwwroot/mysite/images/someimage.jpg", that is the path that you would keep in the database as well. You could also just store the web root relative path, like "/mysite/images/someimage.jpg".

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreColdFusion Development > Help:Uploading an image and saving it in db.


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway