I'm at a loss with an issue that I can't seem to correct.
The client uses the DCR to upload files to a 'temp' directory, in case they change their mind about uploading them at the last second.
Once they hit save, I get a list of all the 'temp' files (as well as a value from a date field on the DCR) and I pass them as strings into the perl script below.
The 2 strings normally come in via cgi but i hard coded them for the code below so you can see them. The strings that come in via CGI are exactly the same as the ones below, I copied and pasted them.
If I'm just uploading one or two files, this works perfectly.
But if I try to do more then 2 or three, it sometimes ignores any additional documents.
So, one time I upload 5 documents and only 4 get processed and moved to the proper folder. The next time I did it, I only had 3 make it through.
With no changes to the code, and no changes as to how I did it in the DCR.
What's even more frustrating is that
when I run this code from the command line, it works perfectly. I can move as many files as I want.
But when it's coming from the DCR being saved it mysteriously stops working.Does anyone have any ideas why that might be happening?
This is my first project as an IW developer and i'm 99.9% done with it, this is the last bug I need to fix.
If you'd like code from another component, please let me know.
[html]
#!E:\iw-home/iw-perl/bin/iwperl -w
use strict;
use TeamSite::CGI_lite;
my $cgi = TeamSite::CGI_lite->new();
$cgi->parse_data();
$folderListString = "01_13_2009,01_13_2009,01_13_2009,01_13_2009,01_13_2009";
$fileListString = "0mypdf.pdf,1mypdf.pdf,2mypdf.pdf,3mypdf.pdf,4mypdf.pdf";
my $rootFolder = "Y:\\default\\main\\******\\WORKAREA\\root\\*****\\regulatory_affairs\\pdfs\\price_summaries\\";
my
@files = split(',', $fileListString);
my
@folders = split(',', $folderListString);
my $count =
@files;
$count--;
for(my $i=0;$i<=$count;$i++)
{
my $fullPath = $rootFolder.$folders[$i];
if (! -d $fullPath)
{
mkdir $fullPath or die "Couldn't create dir ($!)";
}
my $tempFile = "E:\\iw-home\\temp\\price_summaries\\$files[$i]";
my $folder = $folders[$i];
my $file = $files[$i];
my $newFile = "Y:\\default\\main\\******\\WORKAREA\\root\\*****\\regulatory_affairs\\pdfs\\price_summaries\\$folder\\$file";
rename $tempFile, $newFile or die "CANNOT BE DONE $!\n\n";
}
[/html]