S3-Uploads icon indicating copy to clipboard operation
S3-Uploads copied to clipboard

Warning: copy(): The second argument to copy() function cannot be a directory in /var/www/html/wp-content/plugins/s3-uploads/inc/class-s3-uploads.php on line 226

Open trovster opened this issue 5 years ago • 2 comments

When using the plugin and using the upload manually, $upload = wp_handle_sideload($file, array('test_form' => false)); I am getting an error. The second argument passed in to copy is the temporary file name, so I don't know why it is complaining. If I add a file extension, then it works.

trovster avatar Jan 30 '20 11:01 trovster

I have managed to by-pass the problem with the following filter;

function wp_check_filetype_and_ext($wp_check_filetype_and_ext, $file, $filename, $mimes, $real_mime) {
	if (is_array($wp_check_filetype_and_ext) && array_key_exists('ext', $wp_check_filetype_and_ext) && array_key_exists('type', $wp_check_filetype_and_ext)
		&& $wp_check_filetype_and_ext['ext'] === false && $wp_check_filetype_and_ext['type'] === false) {
		// broken because of the S3 location.
		if (strpos($file, 's3://') === 0) {
			return wp_check_filetype($filename, $mimes);
		}
	}

	return $wp_check_filetype_and_ext;
}
add_filter('wp_check_filetype_and_ext', 'wp_check_filetype_and_ext', 10, 5);

trovster avatar Jan 30 '20 14:01 trovster

Is this still an issue in the latest version of the plugin?

archon810 avatar Sep 16 '21 18:09 archon810