in reply to Re: Re: Re: Re: Upload Question
in thread Upload Question
I don't know why you're using sysopen for this, but ok. It's possible since you're using O_EXCL, the sysopen is failing. Straight from perldoc perlopentut:
O_EXCL - Fail if the file already exists
So if the file's already there. Sysopen will fail. Another problem is the fact that sysopen is opening the file for READING ONLY. If you change it to O_CREAT | O_EXCL | O_WRONLY, the file will be open for writing. Finally, you always want to know if the open failed. This can be done quite simply by adding or die $!; to the end. So in summation, you actually want the following line for your sysopen:
sysopen(OUTPUT, $upload_dir . $filename, O_CREAT | O_EXCL | O_WRONLY) +or die $!;
Now please note that if someone tries to upload this file again, the upload will fail. Since the die doesn't present any error message to the end user himself, you may instead want to use -e whick will tell you whether or not the file or directory already exists. You can read more about opening files at perldoc perlopentut as well as file detection switches at perldoc -f -X.
Hope this helps.
antirice
The first rule of Perl club is - use Perl
The ith rule of Perl club is - follow rule i - 1 for i > 1
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Re: Re: Re: Re: Upload Question
by joev (Novice) on Nov 04, 2003 at 23:30 UTC | |
by antirice (Priest) on Nov 05, 2003 at 01:44 UTC |