October CMS How To Change Path Of File Upload?

- 1 answer

I'm using October CMS.

I made a simple front-end File Upload Plugin. I have a Model and Component.

upload form

In Model Uploader.php I use

public $attachOne = [
    'videofile' => 'System\Models\File'

And in the Component

public function onUpload(){
    $uploader = new Uploader();
    $uploader->videofile = Input::file('videofile');
    Flash::success('File Uploaded');
    return Redirect::back();

By default, Uploads go to


The CMS is giving the files a random directory and name.

But backend Media Uploads go to


The File name is preserved.

How do I make the files upload to /media instead of /uploads/public?

Or is it possible to define a folder and filename instead of random in /uploads/public?



You can move the file before attaching it to the Uploader model:

Input::file('videofile')->move($destinationPath, $fileName);

You can get the original filename like this

$name = Input::file('videofile')->getClientOriginalName();