i want to know "how to get the directory path dynamically in the broswer for file uploads.

43 views
Skip to first unread message

harihara...@jothisoftware.com

unread,
Jun 8, 2016, 3:16:49 AM6/8/16
to Mojolicious

hi ,
 

  i want to know "how to get the directory path dynamically in the broswer for file  upload
s.

     Under controller folder.  i used this codes


 package Llogin::Controller::Example;
use Mojo::Base 'Mojolicious::Controller';
use Mojo::Upload;
# This action will render a template
sub welcome {
 
my  $self=shift;
my @files;
    for my $file(@{$self->req->uploads('files')}) {
        my $size = $file->size;
        my $name =$file->filename;
        push @files,"$name ($size)";
        $file->move_to("/home/vagrant/Desktop/projects/llogin/lib/Llogin/Controller/.$name");
        $self->render(text=>"@files");   
       
       
    }
}

1;
Under Template folder.  i used this codes
<html>
<form action="<%= /Controller/ %>" method="GET" enctype="multipart/form-data">
<input name="files" type="file" multiple="multiple">
<button type="submit">upload</button>
</form>
</html>

please i want to know "how to get the file path dynamically in the broswer"



Pavel K

unread,
Jun 8, 2016, 12:37:10 PM6/8/16
to Mojolicious
It's very bad idea save files to controller directory.
For get the directory to upload dynamically see FindBin module.

Joel Berger

unread,
Jun 16, 2016, 11:13:14 AM6/16/16
to Mojolicious
You might want to look into the "home" method on the application, it can be used to find a directory relative to the application's notion of its own path.
Reply all
Reply to author
Forward
0 new messages