afterSave() gives error trying to get property of non-object in octoberCMS


i am trying to get path of uploaded file using fileupload widget and then copying that file in custom folder but when creating new record it gives error <strong>trying to get property 'path' of non-object</strong> when afterSave() calls.


public $attachOne = [ 'file' => ['System\Models\File'] ]; public function afterSave() { $path = $this->file->path; log::info($path); }


replace this afterSave method in your model and it will not show the error you are having.

public function afterSave() { $sessionKey = post('_session_key'); $file = $this->file()->withDeferred($sessionKey)->first(); if($file){ log::info($file->getPath()); } }

the reason is \System\Models\File is available with deferred after master model is commited its changes.

Let me know if you need more help into that.


  • Is it possible to specify 16 colums to bootstrap 3
  • iOS6 hidden status bar
  • Login URL using authentication information in Django
  • Uploading files with asp.net core into database as byte array
  • Using JSON.stringify on object without serializer needs to be marked as experimental
  • Does Tomcat cache compiled JSP pages in memory if scratchdir is read-only?
  • Update statement in MySQL using C#
  • Hibernate Idempotent Update
  • Using MPI_Send/Recv to handle chunk of multi-dim array in Fortran 90
  • getting the values of checkboxes in a checkboxlist control
  • using JQuery autocomplete from database with PHP (CodeIgniter)
  • Shrinking Bootstrap Navbar with logo on scroll
  • watir webdriver - window not found
  • Jenkins - could not read Username for 'https://github.com': No such device or address
  • Sample deviceQuery cuda program
  • Set initial vuetify v-select value
  • playing mp3 from nsbundle
  • How to define something in JavaScript [closed]
  • How to make 100% div height between header and footer?
  • Amazon Elastick BeanStalk error: Failed to create the AWS Elastic Beanstalk application version
  • How do I add a mouse over tooltip to an Image using .DrawImage()
  • Google App Engine Datastore: Dealing with eventual consistency
  • How to decleare char *const argv[] in swift [duplicate]
  • Update cell query for Excel ADO from Delphi
  • ssh remote server login script
  • Grails - How to implement a foreign key relationship not using an id column?
  • Codeigniniter insert data through models and controller
  • How to call different template for different category archive page in woocommerce
  • Sign a Pdf using custom digital signature in Java
  • How do I use TagLib-Sharp to write custom (PRIV) ID3 frames?
  • WPF custom control and direct content support
  • media foundation H264 decoder not working properly
  • CAS 4 - Not able to retrieve the LDAP groups after successful authentication
  • Spring Boot not autowiring @Repository
  • Running R's aov() mixed effects model from Python using rpy2
  • Access to a Matlab gui from the web
  • ARKit code issue {unknown error -1=ffffffffffffffff error: Task failed with exit 1}