A Perl /CGI script to accept different upload files -


related -- https://stackoverflow.com/questions/21487257/a-perl-cgi-script-for-uploading-files -- question, have one: can this: http://www.seaglass.com/file-upload-pl.html script modified accept different input files , save them different output files, , not overwrite single output file? i'm new perl/cgi, wouldn't see obvious answer.

in $basename have name of file. not have write uploaded file /tmp/outfile; can construct path dynamically, depending on $basename.

create directory want place files. assume still c:\tmp. instead of

open(outfile, ">/tmp/outfile") 

write

open(outfile, ">/tmp/$basename") 

and should work. taint removed $upfile inside getbasename(), before $basename created. not safe, still. before giving open(), should remove unwanted characters file name, e.g.

$basename =~ s/[^a-za-z0-9_.-]//g; $basename =~ s/^[^a-za-z0-9]*//; 

if $basename empty now, have chose name other way. if file of same name exists, have choose whether want overwrite or make unique name. current solution overwrites.

if want know more regular expressions, @ perlre manual page.


Comments

Popular posts from this blog

html - Sizing a high-res image (~8MB) to display entirely in a small div (circular, diameter 100px) -

java - IntelliJ - No such instance method -

identifier - Is it possible for an html5 document to have two ids? -