title: Command mv to move file not woking :- mv: cannot move : No such file or directory
body: <p>The foll snippets explains the code in brief :-</p>
  <pre><code>define('UPLOAD_DONE_PATH','');//This comes from config
  $uploaddir = '/home/upload';//This comes as functn parameter
  $uploaddir_done = $uploaddir.UPLOAD_DONE_PATH;
  $uploaddir_done = str_replace(&quot;//&quot;,&quot;/&quot;,$uploaddir_done);
  
  $file_array=array();
  if (is_dir($uploaddir)) {
        if ($dh = opendir($uploaddir)) {
  
              while (($allfile = readdir($dh)) !== false) {
  
                  if ($allfile == '.' or $allfile == '..') continue;
                  {
                     if (strpos($allfile, 'abc') !== false ) {
  
                         $file_array[]=$allfile;
  
                      }
                  }
  
              }
  
              closedir($dh);
  
        }
  }
  
  ...//some code
  
  foreach ($file_array as $key =&gt; $csvfile) {
  
      //Process the file.
  
      //Move the processed file
  
      // Method 1 : Not Working
      // copy file from upload to processed folder
       if (copy($uploaddir.$csvfile,$uploaddir_done.$csvfile)) {
          unlink($uploaddir.$csvfile);
          $this-&gt;log-&gt;info(&quot;CSV file is copy into destination folder.&quot;.PHP_EOL);
        }else{
            $this-&gt;log-&gt;info(&quot;CSV file is not copy into destination folder.&quot;.PHP_EOL);
        }
  
       //Method 2 : Also not working(Move with shell_exec)
       $from = $uploaddir.$csvfile;
       $fromSpace = $from;
          
        $to = $uploaddir_done.$csvfile;
        $toSpace = $to;
          
        $fromSpace = preg_replace('/\s/i', '\\ ', $fromSpace);
        $toSpace = preg_replace('/\s/i', '\\ ', $toSpace);
          
        $ch_permissions = 'sudo chmod +755 -R '.$fromSpace;
        $mv_cmd = 'mv '.$fromSpace.' '.$toSpace;
          
        $ch_permission_result =  shell_exec($ch_permissions);
        $file_move_result =  shell_exec($mv_cmd);
      }
  }
  </code></pre>
  <p>In both cases, Moving the file results in error &quot;mv: cannot move ‘/home/upload/abc 09.25.2020.csv’ to ‘/home/upload/processed/abc 09.25.2020.csv’: No such file or directory
  &quot;
  It appears that this is due to space in filename.How do i go about resolving this?</p>