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'; 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) { if ($user_photo) {
echo ' echo '
<center><img src="'.$user_photo.'" class="img-responsive" alt="'.$user['username'].'" /></center>'; <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 Models\Upload;
use Util\FileSystem; use Util\FileSystem;
/** /**
* Gestione allegati. * Gestione allegati.
* *

View File

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

View File

@ -149,7 +149,7 @@ class User extends Model
$image = Upload::find($this->image_file_id); $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) public function setPhotoAttribute($value)
@ -179,7 +179,7 @@ class User extends Model
$img->save(slashes($file)); $img->save(slashes($file));
// Aggiunta nuova foto // Aggiunta nuova foto
$upload = Upload::build($file, $data); $upload = Upload::build(file_get_contents($file), $data, basename($value['name']));
// Rimozione foto precedenti // Rimozione foto precedenti
delete($file); delete($file);