WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Where should plugins store uploaded (non-attachment/library) files? (4 posts)

  1. timfs
    Member
    Posted 1 year ago #

    Hi,

    I've searched the net and the codex pages for the last two days but I couldn't find an answer, also plugin authors seem to do it in 1000 different ways.

    I'm developing a plugin where i need to upload files, files that do not belong to posts (ie they aren't attachments), shouldn't appear in the media library, and might need to be unpacked into multiple files.

    And now I'm wondering whether there is a "best practice" regarding such uploads made by plugins? Is it ok to store files in the plugin folder, or should the wordpress uploads folder be used? And if the latter is the case, is it ok to use custom sub-folders in the wordpress uploads folder?

    Regards, Tim

  2. bcworkz
    Member
    Posted 1 year ago #

    I'm not aware of a best practice, otherwise there wouldn't be 1000 different ways of doing it. I would use the uploads folder, as you could run into permissions issues anywhere else on some servers. Adding your own sub-folder would be the polite thing to do, and shouldn't create any problems.

    I just found a stray sub-folder in my uploads folder left by a plugin I was testing many months ago, hadn't caused any problems in that time. Somehow be clear that your sub-folder is associated with your plugin so that no one mistakes it for hacker data.

  3. esmi
    Theme Diva & Forum Moderator
    Posted 1 year ago #

    FWIW, the eShop plugin installs its plugin-specific files to wp-content/eshop_files when the plugin is activated. Files that are uploaded by the user via the plugin are stored in wp-content/eshop_downloads.

    HTH

  4. timfs
    Member
    Posted 1 year ago #

    Thanks for your input. I guess I'll give the separate folder in the uploads folder a shot then :)

    Regards, Tim

Topic Closed

This topic has been closed to new replies.

About this Topic