Jump to:

17452 Posts in 4473 Topics by 1971 members


SilverStripe Forums » Archive » SWFUpload Extension

Our old forums are still available as a read-only archive.

Moderators: martimiz, Sean, biapar, Willr, Ingo, simon_w

Page: 1
Go to End
Author Topic: 1891 Views
  • UncleCheese
    4085 Posts

    SWFUpload Extension Link to this post

    This extension allows the integration of the Flash-based upload utility SWFUpload for forms on the frontend or in the CMS.


    - Displays upload progress in real time

    - Interrogates file types and sizes in the dialog box. Ineligible files will be greyed out by the interface.

    - Select multiple files at once for bulk uploading.

    - Configuration is easy using the SWFUploadConfig API. No Javascript necessary.

    - Flash 10 compatible.


    A frontend contact form:

    function ResumeForm()
          return new Form(
             new FieldSet(
                new TextField('Name','* Name'),
                new TextField('Address'),
                new TextField('City'),
                new TextField('State'),
                new NumericField('Zip'),
                new EmailField('Email','* Email'),
              new SWFUploadField(
                   "* Please attach your most current copies of your resume and cover letter (PDF or DOC only). You must submit a resume to be considered.",
                   array (
                      'file_types_list' => '*.doc;*.pdf',
                      'file_queue_limit' => '2',
                      'browse_button_text' => 'Choose files...',
                      'upload_url' => $this->Link('handleswfupload'),
                      'required' => 'true'
             new FieldSet(
                new FormAction('doResumeSubmit','Apply')
             new RequiredFields('Name','College','YearOfGraduation','Email','Phone','Message')

    /** Handle the upload anyway you want **/
       public function handleswfupload()
          if (isset($_FILES["swfupload_file"]) && is_uploaded_file($_FILES["swfupload_file"]["tmp_name"])) {
       $file = new File();
        // store the owner id with the uploaded image
       if($member = Member::currentUser())
          $file->OwnerID = $member->ID;

    /* this gets sent back to the form to an array of hidden inputs called "uploaded_files[]". When the form posts, you can handle the array of Files that were uploaded by their IDs.*/
    echo $file->ID;

          else {
             echo ' '; // return something or SWFUpload won't fire uploadSuccess

    Instead of passing the constructor the array of configuration vars, you can also do this before you instantiate the object:


    For the CMS:

    public function getCMSFields()
    $f = parent::getCMSFields();
    $f->addFieldToTab("Root.Content.MyFile", new SWFUploadFileIFrameField('MyFile','My Label'));
    return $f;

  • Fuzz10
    Community Member
    787 Posts

    Re: SWFUpload Extension Link to this post

    This is brilliant !!

    Thanks for the hard work ! I'll definitely try it out later today.

Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.