Reputation: 445
For a plugin i am creating, i want to create an uploads folder for uploading files temporarily and then after the process is complete, i want to delete those files.
This i have achieved using: $upload_dir = wp_upload_dir();
http://codex.wordpress.org/Function_Reference/wp_upload_dir
How can I be sure that the folder is writable if not the plugin will not function properly.
Upvotes: 0
Views: 420
Reputation: 11808
Instead of relying on if the uploads folder is writable or not and since you are storing your files temporarily, it is a better option that you create a folder in the uploads directory for which you can specify the permissions yourself,
$up_dir = wp_upload_dir();
// Create a folder in the Uploads Directory of WordPress to store your files
if (!file_exists($up_dir['basedir'].'/your_dir_name')) {
mkdir($up_dir['basedir'].'/your_dir_name', 0775, true);
}
Then you can use this location for your plugins file storage.
Upvotes: 2