If you know the file id, it is really simple,
$file = file_load($fid); file_move($file, 'public://new_file_name);
How it works:
We need a source file object to move file to the new location and update the files database entry. Moving a file is performed by copying the file to the new location and then deleting the original. To get source file object, we can use file_load() function.
file_load($fid) - loads a single file object from the database
$fid - file id
return object representing the file, or FALSE if the file was not found.
So I just came back from European Drupal Days in Milan. I had great fun at the event, it was well organized and filled with interesting talks. I'll be sure to attend it next year too!
Originally published on February 23rd, 2015 on NTEN.org. Republished with permission.
For the last 15 years or so, we’ve seen consistent growth in nonprofits’ appreciation for how open source tools can support their goals for online engagement. Rarely do we run across an RFP for a nonprofit website redesign that doesn’t specify either Drupal or WordPress as the preferred CMS platform. The immediate benefits of implementing an open source solution are pretty clear:
With open source tools, organizations avoid costly licensing fees.
Open source tools are generally easier to customize.
Open source tools often have stronger and more diverse vendor/support options.
Open source platforms are often better suited for integration with other tools and services.