Reputation: 4675
I'm using October CMS.
I made a simple front-end File Upload Plugin. I have a Model and Component.
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');
$uploader->save();
Flash::success('File Uploaded');
return Redirect::back();
}
By default, Uploads go to
/storage/app/uploads/public/random-dir/random-name.mp4
The CMS is giving the files a random directory and name.
But backend Media Uploads go to
/storage/app/media/filename.mp4
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?
Upvotes: 1
Views: 2638
Reputation: 1799
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();
Upvotes: 1