Gossamer Forum
Home : General : Perl Programming :

File Upload

Quote Reply
File Upload
Yet another strange problem.

I have this code:

Code:
open U, ">$cfg->{UP_DIR}/$file_name" or $tpl->neat_error(ERROR => $!, %globals);
while (<$file>) {
print U $_;
}
close U;

Inside neat_error I have an exit so no matter what happens, exit is called.

However....the weird problem I'm encountering is that neat_error keeps being called and the error message is "Is a directory" yet the file is uploaded correctly with the correct filename (yellow.jpg) - how can that be?

Last edited by:

RedRum: Oct 12, 2001, 2:09 PM
Quote Reply
Re: [RedRum] File Upload In reply to
Hi,

Is open U, ">$cfg->{UP_DIR}/$file_name" a legal way to open a file (without the parentheses)...?

I always have used
open(HANDLE, ">$filename");

--
Matt G
Quote Reply
Re: [mglaspie] File Upload In reply to
Yes it is fine.
Quote Reply
Re: [RedRum] File Upload In reply to
Hmmm... in that case I'd guess that the problem is with $cfg->{UP_DIR}/$file_name

Maybe its value is not as expected?

--
Matt G
Quote Reply
Re: [RedRum] File Upload In reply to
Time to learn the beauty of stack traces. =) Go to where it's being printed out and add:

use Carp;
Carp::cluck ("how'd I get here?");

then run the script and look at your error log, you'll see a nice stack trace of how you got to that point in the code.

Cheers,

Alex
--
Gossamer Threads Inc.
Quote Reply
Re: [Alex] File Upload In reply to
Thanks Alex - will try that in the morning!

Is it just me that gets all these strange problems or it is an everyday part of writing perl scripts?

Last edited by:

RedRum: Oct 12, 2001, 7:33 PM
Quote Reply
Re: [RedRum] File Upload In reply to
You're not the only one. I think it's part of any programming language. I run into problems like that all the time, even back when I was programming in c/c++ I would see these kind of problems.

Regards,
Charlie