Laravel 5 moving image to another folder dynamically
<p>I have a fileupload module in my app. I can upload files in img/upload/{container_id}/file_name_here. </p>

<p>The {container_id} will depend on what folder the user will use.</p>

<p>The problem I encountered is when they try to edit a record to another folder. The file that they uploaded remains in the old folder.</p>

<p>I want to move the file also to the new folder the user defines.</p>

<p>I have here my code, I'm stuck in moving the file.</p>

<pre><code>$attachments = Attachment::where('document_id',$id)-&gt;select('filename')-&gt;get();
        $document = Document::findOrFail($id);

        foreach($attachments as $attachment)
        {
            $attachment-&gt;filename = base_path().'/public/img/upload/'.$document-&gt;container_id."/".$attachment-&gt;filename;
        }

        Document::findOrFail($id)-&gt;update($request-&gt;all());

        $document = Document::findOrFail($id);

        $x = Attachment::where('document_id','=',$id)-&gt;count();

        foreach($attachments as $file)
        {

            HOW_DO_I_MOVE_THE_FILE????
            $x++;
        }

        return redirect('documents');
</code></pre>