On May 25, 10:16 pm, [EMAIL PROTECTED] ([EMAIL PROTECTED]) wrote: > On May 24, 5:59 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > > > > > On May 24, 2:22 pm, Alma <[EMAIL PROTECTED]> wrote: > > > > Hi All, > > > > I need to store the files > > > What files? Where are the before you "store" them? > > > > in a directory '/home/user/cgi-bin/{today's > > > Date} > > > I am able to creata a folder on daily bases . > > > If that bit's not a problem why do you mention it? > > > > I am struggling to create a subroutine that stores the uploaded pdf > > > file into this today's date directory. > > > Can you explain why you think this would be different for a PDF file > > than for any other sort of file? > > > Can you be more precise about the nature of the diffiulty you are > > having? What have you tried? How did it fail? > > > What do you mean "uploaded"? Is this perhaps a stealth CGI question? > > > If this is a stealth CGI question have you looked at the examples in > > the CGI docmentation? Is there somthing in there you think is unclear? > > Remember as a beginner you are uniquely qualified to tell us when the > > documentation is unclear. > > > Actually looking a the documentation it's poor! > > > It mentions binmode() too late and uses the 2-arg open without > > checking for errors. > > > I would actually use File::Copy. > > > copy(upload('uploaded_file'),"/wherever/$date/$filename") or die $!; > > > You will, of course, have to do something to make sure $filename is > > unique. > > > > & if i need to read the pdf file > > > What do you mean by "read the pdf file"? Do you mean you actually want > > to parse it and extract info? Look on CPAN for modules with PDF in > > their name. > > > > should i be using open file or infile command? > > > What is "infile command"? > > Try this out, there are some changes to the other post. > > #!/usr/bin/perl -w > > use strict; > use File::Copy; > use Time::Local; > > my $destination_folder = "cgi-bin\\"; # path to destination folder > my $source_folder = "C:\\Programming\\test_bed_perl\\"; #path to > source folder > > # add extensions to select those files for copying eg. *.pl would > select file with .pl only. Can select > # multiple extensions ("*.*, *.pls) > my $file_extensions = "*.pdf"; > > my($day, $mon, $yr) = (localtime)[3, 4, 5]; > my $daily_folder = $day . "_" . ($mon + 1) . "_" . ($yr + 1900) ."\\"; > # check epoch if you are going to use date as dir name (UNIX $yr + 30 > i think) > my $start = timelocal(0, 0, 0, $day, $mon, $yr); # 00:00 this morning > my $stop = $start + (24 * 60 * 60 ) - 1; # 23:59:59 > > chdir $destination_folder or die "cannot change dir"; > mkdir "$daily_folder"; > print "directory created: ${destination_folder}${daily_folder}\n"; > > grep { > if ($_ ne $0){ > copy("${source_folder}$_", > "${destination_folder}${daily_folder}$_") > or die "Could not copy source file: $!\n"; > print "copying ${source_folder}$_ -> ${destination_folder}$ > {daily_folder}$_\n"; > unlink("${source_folder}$_") or die "Could not delele source > files: > $!\n"; > print "deleting ${source_folder}$_\n\n"; > } > > } @{&find_files}; > > sub find_files{ > my @files; > > chdir $source_folder; > grep{ > my $timestamp = (stat $_)[9]; > push @files, $_ if $timestamp >= $start && $timestamp <= > $stop; > } glob $file_extensions; > > return [EMAIL PROTECTED]; > > } > > edit the $destination_folder and $source_folder to the directories you > want the files moved to and the original location of the uploads. you > can also edit $file_extensions if you want to filter for a specific > extension eg. ".pdf". > > Can you give me an indication of what you want to do with the opened > pdf?
Thanks a Lot. I do not need to perform any editing tasks on pdf. my requirement is just to upload a pdf & then i need to open it for the read purpose only. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/