I am following this youtube video to learn how to create an image upload form on a page -- which would allow a user to upload an image. About 6 minutes into the video it goes into using php. Does anyone know how I can do this in dancer2 so I won't have to uses php.
Have you ever tried to upload image via cgi? http://www.perlmonks.org/?node_id=575084 <http://www.perlmonks.org/?node_id=575084> http://stackoverflow.com/questions/2272092/why-is-this-perl-cgi-script-faili... <http://stackoverflow.com/questions/2272092/why-is-this-perl-cgi-script-failing-to-upload-images-correctly> ... So this is the very same.
On 05 Sep 2015, at 21:28, Richard Reina <gatorreina@gmail.com> wrote:
I am following this youtube video to learn how to create an image upload form on a page -- which would allow a user to upload an image. About 6 minutes into the video it goes into using php. Does anyone know how I can do this in dancer2 so I won't have to uses php. _______________________________________________ dancer-users mailing list dancer-users@dancer.pm http://lists.preshweb.co.uk/mailman/listinfo/dancer-users
On 09/05/2015 09:28 PM, Richard Reina wrote:
I am following this youtube video to learn how to create an image upload form on a page -- which would allow a user to upload an image. About 6 minutes into the video it goes into using php. Does anyone know how I can do this in dancer2 so I won't have to uses php.
_______________________________________________ dancer-users mailing list dancer-users@dancer.pm http://lists.preshweb.co.uk/mailman/listinfo/dancer-users
Have a look on https://metacpan.org/pod/Dancer::Request::Upload for Dancer2 - Dancer2::Core::Request::Upload. Here is a working example for Dancer: https://github.com/mestia/simpleshare/blob/8129bc86d9f7b524117bc3d392b6f6a8c...
Have a look on https://metacpan.org/pod/Dancer::Request::Upload for Dancer2 - Dancer2::Core::Request::Upload.
Here is a working example for Dancer:
https://github.com/mestia/simpleshare/blob/8129bc86d9f7b524117bc3d392b6f6a8c...
_______________________________________________ dancer-users mailing list dancer-users@dancer.pm http://lists.preshweb.co.uk/mailman/listinfo/dancer-users
Hello Alex and Attila, Been playing with the request->upload example but can't but when I hit upload all that appears is the "1" in the top left corner of the page. my $upload_route = '/upload'; my $upload_dir = '/tmp'; get '/upload' => sub { template 'upload' => { upload_file => $upload_route, }; }; post '/upload' => sub { my $file = request->upload('file'); my $fname = $file->filename; my $tmpname = $file->tempname; my $destination = $upload_dir . '/' . $fname; $file->copy_to($destination); unlink $tmpname if -e $tmpname; print "Done\n"; }; true; Any idea what I might have done wrong?
On 6/09/2015 7:54 am, Richard Reina wrote:
post '/upload' => sub { my $file = request->upload('file'); my $fname = $file->filename; my $tmpname = $file->tempname; my $destination = $upload_dir . '/' . $fname; $file->copy_to($destination); unlink $tmpname if -e $tmpname;
print "Done\n"; };
Note that `print` returns true if successful. The `print` statement is the last one in your route, and the returned value from a route becomes the response content. Hope that helps, Russell.
2015-09-05 17:46 GMT-05:00 Russell Jenkins < russell.jenkins@strategicdata.com.au>:
On 6/09/2015 7:54 am, Richard Reina wrote:
post '/upload' => sub { my $file = request->upload('file'); my $fname = $file->filename; my $tmpname = $file->tempname; my $destination = $upload_dir . '/' . $fname; $file->copy_to($destination); unlink $tmpname if -e $tmpname;
print "Done\n"; };
Note that `print` returns true if successful.
The `print` statement is the last one in your route, and the returned value from a route becomes the response content.
Hope that helps, Russell.
Hi Russell,
Thanks for the reply. I continue to get the same result after I comment out the print statement.
2015-09-05 20:30 GMT-05:00 Richard Reina <gatorreina@gmail.com>:
2015-09-05 17:46 GMT-05:00 Russell Jenkins < russell.jenkins@strategicdata.com.au>:
On 6/09/2015 7:54 am, Richard Reina wrote:
post '/upload' => sub { my $file = request->upload('file'); my $fname = $file->filename; my $tmpname = $file->tempname; my $destination = $upload_dir . '/' . $fname; $file->copy_to($destination); unlink $tmpname if -e $tmpname;
print "Done\n"; };
Note that `print` returns true if successful.
The `print` statement is the last one in your route, and the returned value from a route becomes the response content.
Hope that helps, Russell.
Hi Russell,
Thanks for the reply. I continue to get the same result after I comment out the print statement.
I think the problem was that I forgot to put template 'upload' in the post subroutine.
participants (4)
-
Alex Mestiashvili -
Attila Bárdi -
Richard Reina -
Russell Jenkins