开发者

File transfer all images inside a folder to a destination folder via plugin during activation

开发者 https://www.devze.com 2023-02-16 17:18 出处:网络
I have a WordPress plugin that, when first activated, sets up some default si开发者_如何学运维te settings and creates and adds a few widgets to the site.

I have a WordPress plugin that, when first activated, sets up some default si开发者_如何学运维te settings and creates and adds a few widgets to the site.

I'd like to add some code to my plugin so that during the activation process, it grabs all images inside a folder named "images" (located in the same directory as the plugin script) and transfers them all to the "uploads" folder in WordPress (located at wp-content/uploads).

Can someone provide an example of the code methods required to do this file transfer?


If PHP is running as the owner of the files and directories involved, you can simply call rename with the old location and the new location of each file.

File ownership may be an issue, so your code should be prepared to deal with failures by checking the return value of the function.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号