<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">2016-01-10 1:48 GMT-06:00 Stefan Hornburg (Racke) <span dir="ltr"><<a href="mailto:racke@linuxia.de" target="_blank">racke@linuxia.de</a>></span>:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div class=""><div class="h5">On 01/10/2016 03:35 AM, Richard Reina wrote:<br>
> This code works (the file uploads) when I run it from my web app on my local host. However, it does not when I try it on the digitalocean version of my app. I get no errors and $file->copy_to($destination) returns true. But the file does not upload. Anyone have an idea as to what the problem could be?<br>
><br>
> post '/upload' => sub {<br>
><br>
> my $user_id = session 'UID';<br>
> my $d_filename = 'user_' . $user_id . '.jpg';<br>
><br>
> my $file = request->upload('file');<br>
> my $tmpname = $file->tempname;<br>
> my $destination = $upload_dir . '/' . $d_filename;<br>
> my ($crslt) = $file->copy_to($destination) || warn $!;<br>
> unlink $tmpname if -e $tmpname;<br>
><br>
> debug "crslt: ", $crslt;<br>
><br>
> template 'upload';<br>
><br>
> redirect '/playerdash';<br>
> };<br>
><br>
<br>
</div></div>Where did you define $upload_dir and what is the value of it?<br>
<br>
Regards<br>
<span class=""><font color="#888888"> Racke<br>
</font></span><br></blockquote></div><br><br><div><div><div>Racke and Gabor, Thank you very much for the replies. <br><br></div>$upload_dir
was being set just before the get route -- which I realize is not
correct so I have now put it in the post route like below and the
results are the same. <br><br>Both machines run perl (v5.20.2).<br><br>On the development machine I start Dancer2 with: plackup -r bin/app.psgi<br><br></div>On
the production machine: service starman start; which uses argument:
'/home/starman/Almslete/bin/app.psgi (see <a href="http://starman.pl">starman.pl</a> below) Gabor I
followed your excellent tutorial: <a href="http://perlmaven.com/getting-started-with-perl-dancer-on-digital-ocean" target="_blank">http://perlmaven.com/getting-started-with-<span class="">perl</span>-dancer-on-digital-ocean</a><br><br>post '/upload' => sub {<br><br>my $upload_route = '/upload';<br>my $upload_dir = 'public/profile_pics';<br> <br> my $user_id = session 'UID';<br> my $d_filename = 'user_' . $user_id . '.jpg'; <br> <br> my $file = request->upload('file');<br> my $tmpname = $file->tempname;<br> debug "File Size: ", $file->size; <br> debug "file: ", $file->filename;<br> debug "tmpname: ", $file->tempname, <br> my $destination = $upload_dir . '/' . $d_filename;<br> debug "Destination: $destination\n";<br> my ($crslt) = $file->copy_to($destination) || warn $!;<br> #unlink $tmpname if -e $tmpname;<br><br> debug "crslt: ", $crslt;<br> <br> template 'upload';<br><br> redirect '/playerdash'; <br>};<br><br></div>/home/starman/<a href="http://starman.pl">starman.pl</a><br><br>#!/usr/bin/perl<br><br>use warnings;<br>use strict;<br>use Daemon::Control;<br><br>use Cwd qw(abs_path);<br><br>Daemon::Control->new(<br> {<br> name => "Starman",<br> lsb_start => '$syslog $remote_fs',<br> lsb_stop => '$syslog',<br> lsb_sdesc => 'Starman Short',<br> lsb_desc => 'Starman controls the web sites.',<br> path => abs_path($0),<br><br> #program => 'plackup -E deployment -s Starman',<br> program => '/usr/local/bin/starman',<br> program_args => [ '--workers', '3', '/home/starman/Almslete/bin/app.psgi' ],<br> <br> #plackup -E deployment -s Starman --workers=10 -p 5001 -a bin/app.psgipl <br> user => 'starman',<br> group => 'starman',<br><br> pid_file => '/tmp/starman.pid',<br> stderr_file => '/tmp/starman.err',<br> stdout_file => '/tmp/starman.out',<br><br> fork => 2,<br><br> }<br> )->run;<br><br><br>Thanks again for the help.</div></div>