Hi all,
I'd like to pose the following question:

I am new to perl and I try to make a website using
apache and modperl,
in which authorised users upload files for other users
to download.

For upload, I copy the files in a folder and I put
the filePath in a mySQL db. I am also using a fileID
to refer to the file uploaded.

In the download page there are links like:
href=http://myserver.com/DownloadFiles?fileID=5

When a user requests a file I am using the following
code im my DownloadFiles module:
============================
  $fileID=$r->param($fileID);
  my $filePath=getPathFromDB($fileID);
  if ($filePath) {
    open(FILEHANDLER, "$filePath"); 
    flock(FILEHANDLER,LOCK_SH);
    $r->internal_redirect('$filePath');
    flock(FILEHANDLER,LOCK_UN);
    close(FILEHANDLER); 
  } else {
     printErrorPage();
  }
============================
(I did not use 
while (<FHNDLNAME>) {$r->print($_);}
because most probably it would be slower)

The problem comes when the authorised user wants to
delete a file. When I lock exlusively the file to be
deleted I can not perform an unlink, and unlink does
not
work with a filehandle.In the delete module I use the
following code:
============================
my $filePath=getPathFromDB($fileID);
deleteDBEntry($fileID);

open(FILEHANDLE, "$filePath"); 
flock(FILEHANDLE,LOCK_EX);
        
unlink(FILEHANDLE);# Bareword FILEHANDLE" not allowed 
#while "strict subs" in use.

unlink($filePath);# Can^t delete.
        
flock(FHNDLNAME,LOCK_UN);
close(FHNDLNAME); 
============================
I want to lock the files to be sure that nobody can
read while I perform a delete or even worse a update
file function. Am I totaly wrong in this? 

Many many thanks in advance for your help.

Macis

__________________________________________________
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to