From 38e1f906b0b23bb0c086184bf877b31406751d4c Mon Sep 17 00:00:00 2001 From: champsupertramp Date: Sun, 10 Apr 2016 00:43:08 +0800 Subject: [PATCH] Fix image upload --- core/um-files.php | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/core/um-files.php b/core/um-files.php index 8dcc33c0..47cc33a2 100644 --- a/core/um-files.php +++ b/core/um-files.php @@ -540,15 +540,20 @@ class UM_Files { } $ext = '.' . pathinfo($source, PATHINFO_EXTENSION); - $name = $key; - $filename = $name . $ext; - + // copy & overwrite file + + if( in_array( $key , array('profile_photo','cover_photo') ) ){ + $filename = $key . $ext; + }else{ + $filename = basename( $source ); + } + if ( file_exists( $this->upload_basedir . $user_id . '/' . $filename ) ) { unlink( $this->upload_basedir . $user_id . '/' . $filename ); } copy( $source, $this->upload_basedir . $user_id . '/' . $filename ); - + $info = @getimagesize( $source ); // thumbs @@ -596,9 +601,7 @@ class UM_Files { // removes a synced profile photo delete_user_meta( $user_id, 'synced_profile_photo' ); - } - - if ( $key == 'cover_photo' ) { + }else if ( $key == 'cover_photo' ) { list($w, $h) = @getimagesize( $source ); @@ -636,6 +639,8 @@ class UM_Files { } + }else{ + } // clean up temp