File Upload - Integrity constraint violation: 1062 Duplicate entry '1' for key 'PRIMARY
<p>I'm trying to make File upload image and result is error. The description error the bellow.</p>

<blockquote>
  <p>SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '1' for key 'PRIMARY'</p>
</blockquote>

<p>This code controller
<div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-html lang-html prettyprint-override"><code>public function actionUpload()
        {
           $model = new \app\models\UserPhoto();
           if (\Yii::$app-&gt;request-&gt;post()) {
            $model-&gt;photo = \yii\web\UploadedFile::getInstance($model, 'photo');
            $model-&gt;user_id = \Yii::$app-&gt;user-&gt;id;
            if ($model-&gt;validate()) {
                $saveTo = 'uploads/' . $model-&gt;photo-&gt;baseName . '.' . $model-&gt;photo-&gt;extension;
                if ($model-&gt;photo-&gt;saveAs($saveTo)) {
                    $model-&gt;save(false);
                    Yii::$app-&gt;session-&gt;setFlash('success','Success uploaded !');
                }
            }
        }

        return $this-&gt;render('upload', ['model' =&gt; $model]);      
        }</code></pre>
</div>
</div>
</p>