Categories
reviews symfony

Using of sfWidgetFormInputSWFUploadPlugin

Files uploading is the task which appears basically in every project. And symfony provides good technique to handle files uploading. But sometimes we are looking for the solution which would improve uploading usability and provide the way to track uploading progress. There are a few popular libraries based on Flash technology:

http://code.google.com/p/swfupload/
http://www.uploadify.com/
http://developer.yahoo.com/yui/uploader/

Each has own implementation in symfony but we’d like to mention here about SWFUploadPlugin and the plugin which allows to simplify its embedding into forms:

http://www.symfony-project.org/plugins/sfWidgetFormInputSWFUploadPlugin

This plugin implements form widget which can be added into form’s configuration method as:

        $this->setWidgets(array(
          'upload' => new sfWidgetFormInputSWFUpload()
        ));
 
        $this->setValidators(array(
          'upload' => new sfValidatorFile()
        ));

It’s important to mention here that widget is not perfect and contains hardcoded fields. E.g. if you want to change allow for uploading file types you have to change value of swfupload_file_types directly in plugin code (same should be done for dialog box description: swfupload_file_types_description).

Plugin’s readme provides quick start details so you can easily embed upload widget into your page. One other thing worth to mention – debugging of upload process may be quite frustrating (you can enable “debug” option in line #213 of sfWidgetFormInputSWFUpload.php).

Would be interesting to know if you are using any flash-based uploaders as well and why you like them 🙂