Work with ColdFusion and Flex at Wharton in Philadelphia

The Wharton School of Business was the place where I got to first play with ColdFusion 7 and Flex 1.5 which set me on the road to Macromedia/Adobe technology. It’s been a great ride and I have a lot of fun memories of Wharton. I even helped pull one of my co-workers, Terry Ryan, from Wharton on to the Platform Evangelism team.

If you like the education environment (free tuition is an awesome benefit) and are interested in working with cutting edge Adobe technologies then you’ll be interested to know that Wharton has a job opening for a ColdFusion and Flex developer. You’d be working for one of the best guys I know and working on some very cool projects. If you have any questions, feel free to drop me a note over email (ryan@adobe.com) and I’ll answer any inside questions you have. Relocating to Philadelphia is a requirement.

ColdFusion versus PHP – Uploading a File

I spent part of my vacation digging into PHP. I’d like to be much savvier with PHP because we’ve seen a big chunk of Flex adoption from the PHP community and I’d like to be able to talk to those developers more intelligently. Unfortunately my server-side programming chops are very, very rusty. I started out as a ColdFusion developer and I’ve been able to play with some of the new stuff in ColdFusion 9 but I haven’t built a real CF app in a long time. So I thought I’d do a bit of a comparison and I’ve started doing simple things in PHP and then replicating them in ColdFusion. The first one is file uploading.

Disclaimer: I’m assuming there are things I’m doing wrong. File uploading is fairly basic, but part of the reason I want to blog the basic stuff is so people can let me know where I’m messing up and what I could do better. So flame on in the comments.

The Code Comparison

PHP – file_upload.php

<body>
<?php
     ini_set('display_errors',1);
     error_reporting(E_ALL | E_STRICT);
 
     if(isset($_POST['submitted']))
     {
          if( move_uploaded_file($_FILES['myfile']['tmp_name'], "{$_FILES['myfile']['name']}") )
          {
               print '<p>It verked!</p>';    
          } else {
               print '<p>Problemo!</p>';
          }         
          print_r($_FILES);
     }
?>
     <form action="upload_file.php" enctype="multipart/form-data" method="POST">
          <input type="hidden" name="MAX_FILE_SIZE" value="3000000" />
        <p><input type="file" name="myfile" /></p>
        <p><input type="submit" name="submit" value="Upload" /></p>
        <input type="hidden" name="submitted" value="true" />
    </form>
</body>

ColdFusion – file_upload.cfm

<cfifisDefined("form.submitted">
     <cfset currentPath = getCurrentTemplatePath()>
     <cfset currentDirectory = getDirectoryFromPath(currentPath)>
     <cffile action="upload" nameconflict="overwrite" filefield="form.myfile" destination="#currentDirectory#/coldfusion.gpx"/>
     <cfif cffile.filewassaved eq true>
          <p>It verked!</p>
          <cfdump var="#cffile#"/>
     <cfelse>
          <p>Problemo!</p>
     </cfif>
</cfif>
<body>
     <formaction="upload_file.cfm" enctype="multipart/form-data" method="POST">
        <p><inputtype="file" name="myfile" /></p>
        <p><inputtype="submit" name="submit" value="Upload" /></p>
        <inputtype="hidden" name="submitted" value="true" />
    </form>
</body>

Thoughts

I thought it was interesting how PHP and ColdFusion differ in the actual upload mechanism. Both of them just upload the file to a temporary location but then how the programmer deals with it is different. With PHP, you “move” the file to a location of your choice with the move_uploaded_file method. With ColdFusion you use cffile but call the upload attribute instead of the move attribute. That's why you don't put # signs around the form.myfile attribute because the upload function in cffile uses the POST info and that filefield attribute to do the moving/copying behind the scenes. Not sure which one I like better.

A few other bits. One, ColdFusion seems to give way, way more information about the file you've uploaded. I don't know if there is a way to get that kind of detail from PHP, but with ColdFusion I get a bunch of attributes like filewassaved, fileexisted, filewasappended, serverfileext, serverfilename etc. Some of that I can parse from the PHP information, like the file name and file extension, but other information, like if it was overwritten, or if the file already existed, doesn't seem possible to get with PHP. Two, it is really, really annoying to use a relative file path with ColdFusion. The move_uploaded_file function uses a relative path so it's easy to upload it to the same directory. With ColdFusion it's a pain, which is why I had to set a couple of extra variables. Also, PHP seems to love to check that you're below the max file size. You have to set one in your php.ini file and then send it again as a hidden form field. That seems completely redundant and I can't figure out why they do that.

Like I said above, this is supposed to be a pretty basic example because I want to know if I'm doing something stupid. If so, or if you have any additional info on my thoughts above, let me know.

CFUnited Thoughts

cfunited_logoI had a great week at CFUnited last week and it’s great to see the ColdFusion community continue to set the bar for enthusiasm and camaraderie. Brian Swartzfager, Jeff Coughlin, and Dan Vega have great writeups. Adam Haskell has a rundown of some of the presentations and you can grab some of the slides over at SlideSix.

I was impressed both with the response to our news about ColdFusion 9, the new features, and the Flex track that Andy Powell helped with. Having guys like Doug McCune present alongside ColdFusion rock stars like Ray Camden is great for both communities. ColdFusion has a few new features that are going to lower the barrier for non-CF RIA developers to start using ColdFusion. ColdFusion as a Service makes it easy to use ColdFusion to accomplish things right inside your Flex application — like send an email or generate a document — that you can’t do with just Flex. The ColdFusion-AIR functionality makes online/offline sync (something that’s tough to do) a breeze. We’ve always talked about the fact that ColdFusion is the best middle and back end for creating RIAs and as the sophistication of Flex/AIR have evolved, ColdFusion has kept pace.

And there’s nothing like the ColdFusion community. It’s a welcoming, but still tight-knit community that’s willing to help anyone regardless of skill level. It was great to see people I’ve met on the road and meet a few new people as well. Congrats to the team at Stellr for putting on a great show. I really encourage any Flex (and ColdFusion) developer to check it out. And then come check out 360|Flex. Between these two conferences we’ve got a lot of knowledge out there.

ColdFusion 9 & Flex 4 Application Development: Slides for my CFUnited Talk Tomorrow

I’m a lazy slacker so my talk at CFUnited, ColdFusion 9 & Flex 4: Application Development doesn’t have any session description. I’m assuming that means I’ll probably have 2 people there, especially because it looks like CFUnited has an awesome speaker lineup (yet again) but for anyone who wants them or wants to see what I’ll be talking about I’ve posted my slides below and uploaded them to Share. I’ll be covering the new data wizards in Flash Builder 4, some new features in the Flex 4 SDK, and topping it off with how to use the ColdFusion as a Service feature in your Flex applications.

Public Betas of ColdFusion 9 and ColdFusion Builder

The evangelists have been busy the past month showing off the new features of ColdFusion 9 “Centaur” and ColdFusion Builder during the user group tour and I’m happy to be able to tell everyone that both are now available in public beta on labs. Terry Ryan, Ben, and Adam Lehman all have good writeups of things so I’ll run down a few of my favorite features.

coldfusion_server_logoColdFusion 9 “Centaur”

  • Microsoft Office Integration – With CF 9 you can generate and read from native Office formats like Excel, PowerPoint and Word. The best part? We’ve now got a cfshareportint that is as easy to use as our hooks into Exchange and Active Directory. Making Flex front ends for SharePoint has never been so easy.
  • Scripting Support – As more of a “scripter” than a “tagger” I’m happy to be able to say that you can now use CFSCRIPT for anything in the ColdFusion language. If you don’t want to use tags, you don’t have to.
  • ColdFusion as a Service – My favorite feature bar none, and one I did an AdobeTV episode on (below). You can take some of the great CF tags like cfmail, cfpop, and cfdocument and use them right inside of your Flex application without writing any ColdFusion code.

cf_builder_logoColdFusion Builder “Bolt”

  • Extendable extensions – The CF Builder team has made it really easy to add code generation and other features to the IDE just by writing some CFML. So you can make additions to the IDE just by using some ColdFusion.
  • Server Management – You can manage your servers right from within the IDE. Kind of a handy feature.

So enjoy the new features! ColdFusion Builder plugs nicely in with Flash Builder 4, so you can get your full public beta on with some great Flex/ColdFusion integration.

Flash Catalyst/Builder Screencast

I mentioned this in my post about the Flash Builder and Flash Catalyst Beta launches but I wanted to make sure to give props to the guys at Universal Mind. We worked with Darron Schall and Francisco Inchauste to create a good workflow demo and I think they did a really solid job. A lot of us will be using some parts of this demo on the user group tour and it includes a bunch of new features from Catalyst, from Flash Builder, and ColdFusion 9 so it does a great job of showing off the workflow. I’ll try to post the assets soon as well. I took that demo and created a screencast that shows it off.

flash_catalyst_tutorial_screen1

The screncast walks you through the basic workflow of taking a Photoshop file, importing it into Catalyst, and turning the artwork into components. Then in Flash Builder we use some of the new design-centric development features to wire up that artwork to an actual data source. All of the data is coming from a ColdFusion server using the new ORM/Hibernate functionality.

Heading off to Michigan for some ColdFusion and Flash User Group Meetings

Thanks to Nick and a bunch of folks from the Michigan Adobe community I’m going to be heading out to Lansing and Grand Rapids for a week of customer visits and user group meetings. If you’re in the area then please stop by. Here’s the schedule as it stands now:

Michigan is one of the states I’ve never been to, so I’m looking forward to it. And it’ll be fun to talk to so many different audiences about all kinds of topics. There’s something for everyone next week!

Scotch on the Road: Free Tickets in the Name of Technology Amnesty

A big part of the evangelism team’s job is to get new developers to the Flash Platform. A lot of times it’s a very easy sell. But we can always use the help. That’s why I’m really excited to see the Scotch on the Rocks guys help us out. They’re offering free tickets for non-CFML developers out there to the Scotch on the Rocks events. That means any JSP/PHP/.NET/Rails/whatever developers can get some free tickets to check out one of the Scotch events.

I really wish I could come to these but Andrew and Serge will be there and they’ll be giving some great sessions. So go and enjoy the fun (even if you are a CF developer)!

SlideSix Now Supports Embedding Videos from YouTube and Vimeo

slidesixCrunchGear has a good writeup about the new features in SlideSix, which include the ability to add video from Vimeo and YouTube. Todd Sharp has been busy at work and I’m glad to see SlideSix getting more and more attention (as well as features). It’s all built with Adobe technologies from ColdFusion on the back to Flex on the front. I think a few of us on the evangelism team are planning to start using it to share our presentations with the community, so we’re going to be bugging Todd for more features.