[dancer-users] Code behaves differently on digitalocean.

Richard Reina gatorreina at gmail.com
Sun Jan 10 18:33:16 GMT 2016


2016-01-10 9:55 GMT-06:00 Andrew Beverley <andy at andybev.com>:

> 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
>

Andy, Thanks for the ideas. Absolute paths worked. Thanks again everybody
for the helpful replies.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.preshweb.co.uk/pipermail/dancer-users/attachments/20160110/2525e310/attachment.html>


More information about the dancer-users mailing list