Run a function when new image is uploaded in media library

You can use the wp_handle_upload_prefilter filter hook and it will be called when user will upload the file from admin side.

Or

You can use the wp_handle_upload filter hook for the uploaded file.

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)