powerhouse has asked for the wisdom of the Perl Monks concerning the following question:
$file_name_to_add = $in{up_banner}; $file_name_to_add =~ s/%([A-Fa-f0-9]{2})/pack("c",hex($1))/ge; $ctype = $in{up_banner}; $ctypeb = $in{up_banner}; if ($ctype =~ /([^\/\\]+)$/) {#check if it as \ and / for valid path; $file_name_to_add = $1; $file_name_to_add =~ s/^\.+//; #remove the unwanted / or \ } # Check for File Extensions... (I'm renaming the uploaded # file to a database name that I've retrieved and stored # in the variable $record_id if ($file_name_to_add =~ m/\.gif$/i) { $file_ext = ".gif"; } elsif ($file_name_to_add =~ m/\.jpg$/i) { $file_ext = ".jpg"; } elsif ($file_name_to_add =~ m/\.jpeg$/i) { $file_ext = ".jpg"; } elsif ($file_name_to_add =~ m/\.png$/i) { $file_ext = ".png"; } else { $file_ext = ".gif"; # Default } $record_id .= $file_ext; # Append with the extension. open(OUT,">/home/user/dir/aff/pics/$record_id") or error("Can't open o +utfile (/home/user/dir/aff/pics/$record_id) for writing: $!"); $flen = 0; while (read($ctypeb,$i,1024)) { print OUT $i; $flen = $flen + 1024; } close(OUT); $page_content .= qq~ Length: ,$flen/1024,Kb<br />\n File was saved as $record_id!<br />\n<br />~;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Uploading a image...
by powerhouse (Friar) on Feb 02, 2003 at 07:45 UTC | |
by cchampion (Curate) on Feb 02, 2003 at 07:58 UTC | |
by powerhouse (Friar) on Feb 02, 2003 at 08:22 UTC | |
by thezip (Vicar) on Feb 02, 2003 at 07:52 UTC |