Having problems with file_copy in Drupal 7 In my particular situation I am trying to use Drupal's API to import a bunch of files from my computer into a local Drupal installation.  Seems like a smart idea.  So I have the following function:

  function create_picture_file($filepath, $public_place) {
    global $pic_basepath;
    $filepath = "$pic_basepath/$filepath";
    $file = new stdClass();
    $file-&gt;filename = basename($filepath);
    $file-&gt;filepath = $filepath;
    $file-&gt;filemime = file_get_mimetype($filepath);
    $file-&gt;filesize = filesize($filepath);
    $file-&gt;uid = 1;
    $file-&gt;status = FILE_STATUS_PERMANENT;
    $file-&gt;uri = $filepath;
    $file-&gt;display = 1;
    $file-&gt;description = '';
    print_r($file);
    $file = file_copy($file,"public://$public_place",FILE_EXISTS_REPLACE);
    print_r($file);
    return $file;
  }


You'll notice the two print_r statements towards the bottom.  The first one prints the following:

stdClass Object
(
    [filename] =&gt; Arctic_HE0302_Central_bathy.jpg
    [filepath] =&gt; /home/lpeabody/unclos_data/pics/Arctic_HE0302_Central_bathy.jpg
    [filemime] =&gt; image/jpeg
    [filesize] =&gt; 516130
    [uid] =&gt; 1
    [status] =&gt; 1
    [uri] =&gt; /home/lpeabody/unclos_data/pics/Arctic_HE0302_Central_bathy.jpg
    [display] =&gt; 1
    [description] =&gt; 
)


Which looks good.  The second one, however, print's absolutely nothing.  Any pointers or tips as to what I'm doing wrong maybe?

UPDATE
So the public file directory to which this image is being saved in is region_images.  When this directory exists, nothing get's printed by the second print_r statement.  When I remove the directory and all of it's associated style directories, the second print_r statement prints.  However, it prints the following:

stdClass Object
(
    [filename] =&gt; region_images
    [filepath] =&gt; /home/lpeabody/unclos_data/pics/Arctic_HE0302_Central_bathy.jpg
    [filemime] =&gt; image/jpeg
    [filesize] =&gt; 516130
    [uid] =&gt; 1
    [status] =&gt; 1
    [uri] =&gt; public://region_images
    [display] =&gt; 1
    [description] =&gt; 
    [fid] =&gt; 2595
    [timestamp] =&gt; 1331828075
)


Which is wrong, as [filename] should be Arctic_HE0302_Central_bathy.jpg.  Hopefully this can help shed some light on the situation.
Use "public://$public_place/$file-&gt;filename" as $destination parameter for file_copy().