That was quite an upsetting piece of code to read. I have some new white hairs today :)
I can't pinpoint your exact problem, you need to get down and dirty with debug,
and may I suggest our old friend
print could be put to good effect.
Just from a once over, here's a handful of pointers.
Firstly I think your files are zero length because they are never in the POST in the first place.
I don't see an <input type=file ... anywhere in the form, or I'm not seeing how you get the data
in there.
Upload Multiple and UploadMultiFiles are confusing use of two subs to do the job of one.
You are passing parameters in a nasty way, flattening lists and then splitting them again to
pass multiple parameters. Instead use a list, in the correct context a reference is automatically passed.
There are some confusing constructs in there. Study the use of
for and you will see that
you can just say for(@array) without all those redundant indexes everywhere.
I think the whole thing would benefit from using a hash to hold all the datums, the path, the file, the associate
and the description as keys. Copy these from the cgi query hash. You should be able to reduce the whole tangled
pit of misery to 20 lines or less. Your problem with uploadInfo is that the $filehandles list doesn't contain a valid hashref, or $i is out of range.
Heres a few comments
10 require "settings.pl"; # where is this?
12 umask(000); # this is asking for trouble
28 my $image = param('uniquecode'); # poor security, good as
+ useless
37-48 my ($tempError,$error,$name); # you're using a sub
+ just to set a global
162 my ($paths,$newnames,$capts,$associate) = @_; # passing in a
+ flattened list and expanding it is silly
163 my @filehandles = split(/\|/,$paths); # use list ref ins
+tead and save loads of code
171 binmode $filenames[$i]; # operates on filehandle
+ not scalar
Best of luck
Andy
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.