ColdFusion and Flex Multiple Upload UI

Anyone have any experience with this?

Page 1 of 1

4 Replies - 4374 Views - Last Post: 31 December 2008 - 09:19 AM Rate Topic: -----

#1 midasxl  Icon User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 193
  • Joined: 03-December 08

ColdFusion and Flex Multiple Upload UI

Post icon  Posted 29 December 2008 - 11:46 AM

Hello and thanks again for your time. Does anyone have any experience with this UI????

Multiple File Upload with Flex and ColdFusion

I have this nifty UI up and running and have successfully uploaded multiple images into a designated folder. What I would also like to do is insert these same images into a database. Here is the .cfm action page...


<cftry>

	<cffile action="upload" 
			filefield="filedata" 
			destination="#ExpandPath('\')#MultiFileUpload\uploads\" 
			nameconflict="makeunique" 
			accept="application/octet-stream"/>
		
		<cfset acceptedFileExtensions = "jpg,jpeg,gif,png,pdf,flv,txt,doc,rtf"/>
		<cfset filecheck = listFindNoCase(acceptedFileExtensions,File.ServerFileExt)/>


		<cfif filecheck eq false>
			<cffile action="delete" file="#ExpandPath('\')#MultiFileUpload\uploads\#File.ServerFile#"/>
		</cfif>
		
<!---<cfquery name="insertDetails" datasource="gallery">
INSERT INTO tblImages (title, desc, thumb, img)
VALUES ('#serverFile#','#serverFile#','#serverFile#','#serverFile#')
</cfquery>--->

		<cfcatch type="any">
			<cfdocument format="PDF" overwrite="yes" filename="errordebug.pdf">
				<cfdump var="#cfcatch#"/>
			</cfdocument>
		</cfcatch>
</cftry>



The commented area within the code is not part of the original. It is what I have added to attempt to get information into a MS Access database. Nothing shows up in the database however. Any comments, tips, or tricks will be greatly appreciated. Thank you!!

Is This A Good Question/Topic? 0
  • +

Replies To: ColdFusion and Flex Multiple Upload UI

#2 midasxl  Icon User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 193
  • Joined: 03-December 08

Re: ColdFusion and Flex Multiple Upload UI

Posted 30 December 2008 - 07:27 AM

OK, so I figured this out. I had a syntax error in the INSERT INTO statement. My bad. How do I delete this entire thing since it is of no use to anyone now?
Was This Post Helpful? 0
  • +
  • -

#3 CR250  Icon User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 58
  • Joined: 14-June 08

Re: ColdFusion and Flex Multiple Upload UI

Posted 30 December 2008 - 08:14 AM

View Postmidasxl, on 30 Dec, 2008 - 06:27 AM, said:

OK, so I figured this out. I had a syntax error in the INSERT INTO statement. My bad. How do I delete this entire thing since it is of no use to anyone now?


Actually leave it I'll presume you are using this: http://www.adobe.com...ile_upload.html

People are always asking for multifile upload and the more references there are to it the better IMO.

Glad you got it working.
Was This Post Helpful? 0
  • +
  • -

#4 sansclue  Icon User is offline

  • D.I.C Regular

Reputation: 29
  • View blog
  • Posts: 316
  • Joined: 21-November 07

Re: ColdFusion and Flex Multiple Upload UI

Posted 30 December 2008 - 08:54 PM

View Postmidasxl, on 30 Dec, 2008 - 06:27 AM, said:

OK, so I figured this out. I had a syntax error in the INSERT INTO statement. My bad. How do I delete this entire thing since it is of no use to anyone now?

INSERT INTO tblImages (title, desc, thumb, img)


I suspect it was because of the column named DESC. That is a reserved word in most databases. BTW, having nothing to do with anything ;-) ...


> #File.ServerFile#

1) FILE is deprecated. So you should use CFFILE instead or the result attribute. That way your code will still work if they decide to drop FILE entirely or use it for something else in the next version ;-)


2) It is a good practice to always scope variables. That avoids nasty surprises if you accidentally use the same variable name in two different scopes.

ie: use

VALUES ('#CFFILE.serverFile#', ...... )

instead of:

VALUES ('#serverFile#', ..... )
Was This Post Helpful? 0
  • +
  • -

#5 midasxl  Icon User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 193
  • Joined: 03-December 08

Re: ColdFusion and Flex Multiple Upload UI

Posted 31 December 2008 - 09:19 AM

Great! Thanks for the input. I would be happy to leave it up for all to reference. I have made the changes suggested by sansclue, and the result is the code that follows. This is the complete code which performs many functions based on my needs.

First it performs the upload action to four separate directories.
Then it checks to make sure the extensions are acceptable, if not it immediately deletes the files.
Then it inserts data to two separate databases.
A pdf is generated if any errors occur (hmmm...this should probably go at the end of the script).
Finally two XML files are generated based on two database queries. The XML files are then written to their respective directories where they are used to populate my two flash galleries.

That's it! Hope this is helpful to all who see it! Thanks!!


<cftry>

<cffile action="upload" 
			filefield="filedata" 
			destination="#ExpandPath('\')#MultiFileUpload\flash_gallery\images\" 
			nameconflict="overwrite" 
			accept="application/octet-stream"/>	
			
<cffile action="upload" 
			filefield="filedata" 
			destination="#ExpandPath('\')#MultiFileUpload\flash_gallery\images\thumbs\" 
			nameconflict="overwrite" 
			accept="application/octet-stream"/>  
			
<cffile action="upload" 
			filefield="filedata" 
			destination="#ExpandPath('\')#MultiFileUpload\flash_gallery2\files\" 
			nameconflict="overwrite" 
			accept="application/octet-stream"/>  
			
<cffile action="upload" 
			filefield="filedata" 
			destination="#ExpandPath('\')#MultiFileUpload\flash_gallery2\thumbs\" 
			nameconflict="overwrite" 
			accept="application/octet-stream"/>		   
			
		
		<cfset acceptedFileExtensions = "jpg,jpeg,gif,png,pdf,flv,txt,doc,rtf"/>
		<cfset filecheck = listFindNoCase(acceptedFileExtensions,File.ServerFileExt)/>

		<cfif filecheck eq false>
		<cffile action="delete" file="#ExpandPath('\') #MultiFileUpload\flash_gallery\images\#CFFILE.serverFile#"/>
		</cfif>
		
		<cfif filecheck eq false>
			<cffile action="delete" file="#ExpandPath('\')#MultiFileUpload\flash_gallery\images\thumbs\#CFFILE.serverFile#"/>
		</cfif>
		
		<cfif filecheck eq false>
			<cffile action="delete" file="#ExpandPath('\')#MultiFileUpload\flash_gallery2\files\#CFFILE.serverFile#"/>
		</cfif>
		
		<cfif filecheck eq false>
			<cffile action="delete" file="#ExpandPath('\')#MultiFileUpload\flash_gallery2\thumbs\#CFFILE.serverFile#"/>
		</cfif>
		
		<cfquery name="InsertDetails" datasource="data">
	  INSERT INTO pics(albumID, title, caption, thumb, image) 
	  VALUES (1,'#CFFILE.serverFile#','#CFFILE.serverFile#','#CFFILE.serverFile#','#CFFILE.serverFile#') 
	  </cfquery>
	  
	  <cfquery name="InsertDetails" datasource="data2">
	  INSERT INTO tblImages(categoryID, name, thumb, file, description)
	  VALUES (1,'#CFFILE.serverFile#','#CFFILE.serverFile#','#CFFILE.serverFile#','#CFFILE.serverFile#')
	  </cfquery>
		

		<cfcatch type="any">
			<cfdocument format="PDF" overwrite="yes" filename="errordebug.pdf">
				<cfdump var="#cfcatch#"/>
			</cfdocument>
		</cfcatch>
</cftry>


<cfquery name="category" datasource="data">
SELECT categoryID, name, active
FROM category
WHERE active = 1
ORDER BY categoryID ASC
</cfquery>


<cfquery name="images" datasource="data">
SELECT imgID, albumID, title, caption, thumb, image, active
FROM pics
WHERE active = 1
ORDER BY imgID ASC
</cfquery>


<cfprocessingdirective suppresswhitespace="yes">

<cfxml variable="xmlobject" casesensitive="yes">

<gallery title="Directory" thumbDir="./images/thumbs/" imageDir="./images/" random="true">
	<cfoutput>
	<!--- Outer Loop to handle Albums--->
	<cfloop query="category">
		<category name="#XmlFormat(category.name)#">
				
	  <!--- Inner Loop to handle all images --->
	  <cfloop query="images">
	  <cfif category.categoryID IS images.albumID>
			  <image>
				<title>#XmlFormat(images.title)#</title>
				<desc>#XmlFormat(images.caption)#</desc>
				<thumb>#XmlFormat(images.thumb)#</thumb>
				<img>#XmlFormat(images.image)#</img>
			</image>
	   </cfif>
	   </cfloop>
	   </category>
	 </cfloop>
  </cfoutput>
</gallery>

</cfxml>
</cfprocessingdirective>


<cfset xmlString = ToString(xmlobject)>
<cffile action="write" file="C:\ColdFusion8\wwwroot\MultiFileUpload\flash_gallery\gallery.xml" output="#xmlString#">


<cfcontent type="text/xml"><cfoutput>#xmlString#</cfoutput>--->

<!---XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXflash gallery 2 xml creationXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX--->

<cfquery name="category" datasource="data2">
SELECT categoryID, name, active
FROM tblCategories
WHERE active = 1
ORDER BY categoryID ASC
</cfquery>

<cfquery name="images" datasource="data2">
SELECT imageID, categoryID, name, thumb, file, description, active
FROM tblImages
WHERE active = 1
ORDER BY imageID ASC
</cfquery>

<cfprocessingdirective suppresswhitespace="yes">

<cfxml variable="xmlobject" casesensitive="yes">

<data>
	<cfoutput>
	<!--- Outer Loop to handle Albums--->
	<cfloop query="category">
		<category name="#XmlFormat(category.name)#">
				
	  <!--- Inner Loop to handle all images --->
	  <cfloop query="images">
	  <cfif category.categoryID IS images.categoryID>
	 <file name="#XmlFormat(images.name)#"
				thumb="thumbs/#XmlFormat(images.thumb)#"
				file="files/#XmlFormat(images.file)#">
				<![CDATA[#XmlFormat(images.description)#]]>
				</file>
				
	   </cfif>
	   </cfloop>
	   </category>
	 </cfloop>
   </cfoutput>
</data>

</cfxml>
</cfprocessingdirective>

<cfset xmlString = ToString(xmlobject)>
<cffile action="write" file="C:\ColdFusion8\wwwroot\MultiFileUpload\flash_gallery2\data.xml" output="#xmlString#">

<cfcontent type="text/xml"><cfoutput>#xmlString#</cfoutput>--->

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1