in reply to Re: Problems deleting a file.
in thread Problems deleting a file.

I checked the permissions and it has all the necessary permissions. Here is an example of the code, I'm probably way off first time trying to do something like this:
$filekey = $cgi->param("doc_file"); unlink($filekey) if -e $pubFile_path$filekey; if ($filekey) { if ($filekey =~ /([^\/\\]+)$/) { $filename = $1; ($ext) = $filename =~ /(\.\w+)$/; } else { return "You attempted to upload <B>$filekey</B> that isn't properly fo +rmatted. Please rename the file on your computer, and attempt to uplo +ad it again. Files may not have forward or backward slashes in their +names. Also, they may not be prefixed with one (or more) periods."; } $path = $pubFile_path . "/" . $count . $ext; open(OUTFILE, ">$path") or &script_err("Unable to open $path \nReason +: $!");; binmode(OUTFILE); while ($bytes = read($filekey,$buffer,1024)) { $totalbytes += $bytes; print OUTFILE $buffer; } close(OUTFILE); }

Replies are listed 'Best First'.
Re: Re: Re: Problems deleting a file.
by tachyon (Chancellor) on Oct 16, 2002 at 22:56 UTC

    Include the full path to the file and it will work provided your script (generally user nobody) has sufficient rights. ALWAYS check your return values and you will ALWAYS (almost ;-) know why things don't work if they fail....

    my $fullpath = $webserver.$path.$to.$file; unlink $fullpath or dienice("Can't unline '$fullpath' Perl says the error is $!"); # with CGI let's avoid a 500 error sub dienice { print "Content-type: text/html\n\n" . shift; }

    You also have typo's in your post that will stop it working FWIW

    tachyon

    s&&rsenoyhcatreve&&&s&n.+t&"$'$`$\"$\&"&ee&&y&srve&&d&&print