As @jgraup pointed out. You can use the filter wp_handle_upload
. The final code will look like something what is pasted below. You might want to use only one of the two hooks or maybe both of them.
add_filter('wp_handle_upload_prefilter', 'startOfWpHandleUpload', 10, 2 );
function startOfWpHandleUpload( $file ) {
/* Here you can access the following properties of the uploaded file
* before it is processed by the wp_handle_upload function.
*/
/* Name of the uploaded file. */
$file['name'];
/* MIME Type of the uploaded file. */
$file['type'];
/* Temporary location of the stored file. */
$file['tmp_name'];
/* "0" for no errror. Don't know what is for error. */
$file['error'];
/* size in bytes of the uploaded file. */
$file['size'];
return $file;
}
add_filter('wp_handle_upload', 'endOfWpHandleUpload', 10, 2 );
function endOfWpHandleUpload( $file, $type ) {
/* Here you can access the following properties of the uploaded file
* before it is processed by the wp_handle_upload function.
*/
/* Absolute path of the file on the filesystem of the operating system. */
$file['file'];
/* Public accessible URL of the file over the Internet. */
$file['url'];
/* MIME type of the file. */
$file['type'];
return $file;
}
add_action('wp_handle_upload', function($image_data){} );
and wordpress.stackexchange.com/a/16840/84219