Jump to:

7940 Posts in 1543 Topics by 946 members

DataObjectManager Module

SilverStripe Forums » DataObjectManager Module » Change SWFUpload upload directory

Discuss the DataObjectManager module, and the related ImageGallery module.

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

Page: 1
Go to End
Author Topic: 2423 Views
  • theoldlr
    Avatar
    Community Member
    103 Posts

    Change SWFUpload upload directory Link to this post

    Can you change the location of where files are uploaded to? In the documentation it says:

    Parameter name     Default Value     Purpose

    file_destination_path   none   DEPRECATED

    Thanks!

  • UncleCheese
    Avatar
    4085 Posts

    Re: Change SWFUpload upload directory Link to this post

    Depends on the context. If you're using a FileDataObjectManager, which is the context of most SWFUpload usage, you can just do:

    $my_dom->setUploadDir("some/path");

    But if you're using SWFUpload elsewhere, fallback on the config:

    SWFUploadConfig::set_var('default_upload_dir', 'some/path');

  • theoldlr
    Avatar
    Community Member
    103 Posts

    Re: Change SWFUpload upload directory Link to this post

    I tried using the Config as you suggested, and maybe there is an updated way to do what I want now, but I was following the documentation. The file still ends up in the assets/Uploads folder.

    Here is my code:

    public function UploadForm()
    {
    SWFUploadConfig::set_var('default_upload_dir', 'assets/Upload/ForFab');

    return new Form(
    $this,
    "UploadForm",
    new FieldSet(
    new TextField('Name'),
    new EmailField('Email'),
    new SWFUploadField(
    "UploadForm",
    "Drawings",
    "Upload your drawing files...",
    array(
    'required' => 'true',
    'browse_button_text' => 'Choose your file(s)'

    )
    )
    ),
    new FieldSet(
    new FormAction('doUploadSubmit', 'Send File')
    )
    );

    }

  • UncleCheese
    Avatar
    4085 Posts

    Re: Change SWFUpload upload directory Link to this post

    It belongs in _config.php, not your UploadForm function. It only counts when the handleswfupload() function runs. UploadForm() is not in play when the file is written.

    2423 Views
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.