Rename attachments during upload no matter what filetype

Simply decide this on what data you got for your file (I use $file instead of $arr as argument, as it’s easier to understand later).

if ( 'image' == array_shift( explode( "https://wordpress.stackexchange.com/", $file['type'] ) ) )
    // do wonderful things

You can always simply look into what you got with adding the following line to your filter:

exit( printf( '<pre>%s</pre>', var_export( $file, true ) ) );

This will exit during the upload and stop the process, so you can inspect the output and see what data you got from your upload. Just do this for different file types and alter your code according to it.

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