[dancer-users] Code behaves differently on digitalocean.

Andrew Beverley andy at andybev.com
Sun Jan 10 15:55:55 GMT 2016


On Sun, 2016-01-10 at 07:39 -0600, Richard Reina wrote:
> $upload_dir was being set just before the get route -- which I realize 
> is not correct

As an aside, it's probably best practice to define in your config file,
rather than hard-coding into your code. That won't be a cause of your
problem though.

> post '/upload' => sub {
> 
> my $upload_route = '/upload';
> my $upload_dir = 'public/profile_pics';

Have you tried using an absolute path? Or even tried something with open
permissions like "/tmp"?

>     my $user_id = session 'UID';
>     my $d_filename = 'user_' . $user_id . '.jpg';
> 
>     my $file = request->upload('file');
>         my $tmpname = $file->tempname;
>         debug "File Size: ", $file->size;
>         debug "file: ", $file->filename;
>         debug "tmpname: ", $file->tempname,
>         my $destination = $upload_dir . '/' . $d_filename;
>         debug "Destination: $destination\n";
>         my ($crslt) = $file->copy_to($destination) || warn $!;

Do you get any warnings here? TBH, I don't even know if the precedence
of the operators there will work correctly. I would always use "or"
instead of "||" in a situation like that.

It would also be worth doing a "warn 'test'" to check that your warnings
are being logged somewhere that you can see them.

Andy




More information about the dancer-users mailing list