Return false edit Articles with picture

I have trouble while editing article content picture, inside Controller functiion edit below this

use Cake\ORM\TableRegistry;
use Cake\Http\ServerRequest;
use Cake\Datasource\EntityInterface;
use Cake\Filesystem\File;

public function edit($id = null)
        $article = $this->Articles->get($id, [
            'contain' => ['Comments', 'Tags']
		$article->user_id = $this->request->getSession()->read('Auth.User.ID');
		$article->Diubah = (Time::now())->i18nFormat('dd-MM-yyyy HH:mm:ss');
        if ($this->request->is(['patch', 'post', 'put'])) {
			$idgbrarticle = $this->Articles->findById($id)->firstOrFail();
			$hpsgbr = new File(WWW_ROOT . '/files/Articles/photo/' . $idgbrarticle->photo);
			$photo = $this->request->getUploadedFile('');
			$idgbrarticle2 = $this->Articles->findById($id)->firstOrFail();
			$jalur = new File(WWW_ROOT . '/files/Articles/photo/' . $idgbrarticle2->photo);
			$article->photo = $photo;
			$article->photo_dir = $jalur;
			$articletxt = $this->Articles->patchEntity($article, $this->request->getData());
			if ($this->Articles->save($articletxt)){
				$this->Flash->success(__('Artikel beserta gambar,berhasil diperbarui'));
				return $this->redirect(['action' => 'index']);
				$this->Flash->error(__('Artikel beserta gambar,gagal diperbarui,coba lagi'));
        $users = $this->Articles->Users->find('list', ['limit' => 200]);
        $comments = $this->Articles->Comments->find('list', ['limit' => 200]);
        $tags = $this->Articles->Tags->find('list', ['limit' => 200]);
        $this->set(compact('article', 'users', 'comments', 'tags'));

then I was test the function, then the error messages shown below

Cannot convert value of type `Cake\Filesystem\File` to string 

Could this be caused by using Auto-Tables?

Some of the Table objects in your application were created by instantiating "Cake\ORM\Table" instead of any other specific subclass.

This could be the cause for this exception. Auto-Tables are created for you under the following circumstances:

    The class for the specified table does not exist.
    The Table was created with a typo: $this->getTableLocator()->get('Atricles');
    The class file has a typo in the name or incorrect namespace: class Atricles extends Table
    The file containing the class has a typo or incorrect casing: Atricles.php
    The Table was used using associations but the association has a typo: $this->belongsTo('Atricles')
    The table class resides in a Plugin but no plugin notation was used in the association definition.

Please try correcting the issue for the following table aliases:


red error highlight
Cannot convert value of type "Cake\Filesystem\File" to string

is working success when I was test inside
Controller function delete()

so changing the code inside Controller function delete()
or remove Use Cake\Filesystem\File is immpossible.

I hope someone can help me to fix that, thanx