How to use file_save to store pictures into a folder on server? what i want to perform (globally) is to import a csv file that contains data such as book_title, author, and the cover image of the books. The csv file is loaded, book_title and author are stored in their respective tables but for pictures, what i want is to put them manually (ftp for example) on a folder (doesn't matter if it's my default public folder or a new one) and store data in tables like : file_managed and field_data_field_cover_picture etc
In my csv file, and for pictures column i just write filenames of every picture.

At the moment, i'm confused and this is my actual code :

$filename_cover = $get_filename.'.jpg'; &lt;===from csv

        $add_cover_file = db_insert('file_managed')
        // -&gt;key(array('fid' =&gt; rand()))
        -&gt;fields(array(
            'uid' =&gt; $user-&gt;uid,
            'filename' =&gt; $filename_cover ,
            'uri' =&gt; 'public://couvertures/'.$filename_couv,&lt;==my file 
            'filemime' =&gt; 'application/octet-stream',
            'status' =&gt; 1,
            'timestamp' =&gt; time()
        ))
        -&gt;execute();


Now adding on the pictures covers table : (how to put the fid ?)

  $add_couverture = db_merge('field_data_field_photo_de_couverture')
        -&gt;key(array('entity_id' =&gt; $newNode-&gt;nid, 'field_photo_de_couverture_fid'=&gt;$add_couv_file-&gt;fid ))
        -&gt;fields(array(
            'field_photo_de_couverture_fid'=&gt;$get_fid ,
            'entity_id' =&gt; $newNode-&gt;nid,
            'delta' =&gt; 0,
            'bundle' =&gt; 'livre',
            'entity_type' =&gt; 'node'
        ))
        -&gt;execute();
Try this:

$file = file_save((object)array(
    'filename' =&gt; $file_name,
    'uri' =&gt; $destination_uri,
    'status' =&gt; FILE_STATUS_PERMANENT,
    'filemime' =&gt; file_get_mimetype($destination_uri),
  ));
//at that point you can use the $file-&gt;fid
//do the magic on your custom table field_data_field_photo_de_couverture