I've been testing the Wordpress Playground with my plugin. My plugin offers a way to upload a file to wp-content/uploads/ and it seems to work in the playground.
$file_name = $file['name'];
$temp_file = $file['tmp_name'];
//Move uploaded file to Wordpress upload folder
$upload_dir = wp_upload_dir();
$destination = $upload_dir['basedir'] . '/' . $file_name;
if (move_uploaded_file($temp_file, $destination))
{
$file_url = $upload_dir['baseurl'] . '/' . $file_name;
echo json_encode( __('File uploaded successfully', 'csv-to-html') . ': ' . $file_url);
}
The file uploaded successfully prints out and I see that file is in that location (I have a function that scans a folder (wp-content/uploads) and I see that the file exists there), but WHEN I try to read this file into an array I get a permission denied.
So I can write the file but I can't read it. The code is for reading is:
//$file is path to wp-content/uploads/ with the actual filename
//included, e.g. wp-content/uploads/books.csv
$arr_from_file = array_filter( file( $file, FILE_IGNORE_NEW_LINES ) );
This code works perfect locally and on other external sites. The plugin has 500+ active users, so I really don't know how to do a workaround to get this to work in the Wordpress playground. Thoughts?