SASBurns has asked for the wisdom of the Perl Monks concerning the following question:
Here's my Perl Code:<!-- MY HTML FORM --> <form action="upload.pl" method="post" enctype="multipart/form-data"> <div class="image-editor"> <input type="file" class="cropit-image-input" /> <div class="cropit-preview"></div> <div class="image-size-label"> Resize Image: </div> <input type="range" class="cropit-image-zoom-input" /> <input type="hidden" name="imagedata" class="hidden-image-data" /> <button type="submit">save</button> </div> </form> <!-- END OF HTML FORM -->
It keeps uploading a unreadable/corrupted image file please help! thank you.#!/usr/bin/perl use strict; use warnings; use CGI; use MIME::Base64; my $arg=new CGI; my $fetch_photo=$arg->param('imagedata'); my $decoded=MIME::Base64::decode_base64($fetch_photo); my $filename; $filename=int rand(1000).".png" if $fetch_photo=~/png/; $filename=int rand(1000).".jpg" if $fetch_photo=~/jpg/; open(FILE, ">img/$filename") or die 'err'; binmode FILE; print FILE $decoded; close(FILE);
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: uploading a data:image/imagetype,base64 in perl
by Mr. Muskrat (Canon) on Dec 04, 2017 at 20:14 UTC | |
Re: uploading a data:image/imagetype,base64 in perl
by Corion (Patriarch) on Dec 04, 2017 at 18:36 UTC |