diff --git a/fotostore.pl b/fotostore.pl index f4f0760..203f0a1 100755 --- a/fotostore.pl +++ b/fotostore.pl @@ -144,6 +144,7 @@ get '/get_images' => ( authenticated => 1 ) => sub { for my $img_item (@$files_list) { my $file = $img_item->{'file_name'}; my $img_hash = {}; + $img_hash->{'filename'} = $img_item->{'original_filename'}; $img_hash->{'original_url'} = File::Spec->catfile( '/', $IMAGE_BASE, $current_user->{'user_id'}, $ORIG_DIR, $file ); $img_hash->{'thumbnail_url'} = File::Spec->catfile( '/', $IMAGE_BASE, $current_user->{'user_id'}, $thumbs_size, $file ); @@ -233,7 +234,7 @@ post '/upload' => ( authenticated => 1 ) => sub { or die $scaled->errstr; } - if ( !$db->add_file( $user->{'user_id'}, $filename ) ) { + if ( !$db->add_file( $user->{'user_id'}, $filename, $image->filename) ) { #TODO: Send error msg } diff --git a/lib/FotoStore/DB.pm b/lib/FotoStore/DB.pm index 8947fc3..49dea87 100644 --- a/lib/FotoStore/DB.pm +++ b/lib/FotoStore/DB.pm @@ -51,8 +51,8 @@ sub add_user($self, $username, $password, $fullname) { } -sub add_file($self, $user_id, $filename) { - my $rows = $self->{'dbh'}->do(q~insert into images (owner_id, file_name) values (?, ?)~, undef, ($user_id, $filename)); +sub add_file($self, $user_id, $filename, $original_filename) { + my $rows = $self->{'dbh'}->do(q~insert into images (owner_id, file_name, original_filename) values (?, ?, ?)~, undef, ($user_id, $filename, $original_filename)); if ($self->{'dbh'}->errstr) { die $self->{'dbh'}->errstr; } diff --git a/templates/includes/images_list.html.ep b/templates/includes/images_list.html.ep index 16d63c9..5649542 100644 --- a/templates/includes/images_list.html.ep +++ b/templates/includes/images_list.html.ep @@ -38,7 +38,8 @@