Fix upload immagine utente

This commit is contained in:
valentina 2024-08-26 12:30:39 +02:00
parent 9be5d8c9e3
commit 8fd28e8932
4 changed files with 8 additions and 4 deletions

View File

@ -18,8 +18,10 @@
*/
include_once __DIR__.'/../../core.php';
use Models\Upload;
$user_photo = $rootdir.'/files/utenti/'.Upload::find($user->image_file_id)->filename;
$user_photo = $user->photo;
if ($user_photo) {
echo '
<center><img src="'.$user_photo.'" class="img-responsive" alt="'.$user['username'].'" /></center>';

View File

@ -22,6 +22,7 @@ namespace HTMLBuilder\Manager;
use Models\Upload;
use Util\FileSystem;
/**
* Gestione allegati.
*

View File

@ -74,8 +74,9 @@ class Upload extends Model
$model = new static();
// Informazioni di base
$original_name = $source['name'] ?? basename($source);
$name = $data['name'] ?? $name;
$name ??= basename($source);
$original_name = $source['name'] ?? $name;
$category = $data['category'] ?? $category;
// Nome e categoria dell'allegato

View File

@ -149,7 +149,7 @@ class User extends Model
$image = Upload::find($this->image_file_id);
return base_path().'/'.$image->filepath;
return base_path().'/files/'.$image->module->directory.'/'.$image->filename;
}
public function setPhotoAttribute($value)
@ -179,7 +179,7 @@ class User extends Model
$img->save(slashes($file));
// Aggiunta nuova foto
$upload = Upload::build($file, $data);
$upload = Upload::build(file_get_contents($file), $data, basename($value['name']));
// Rimozione foto precedenti
delete($file);