in reply to YAF(ile)U(ploading)Q(uestion)

You're asking where/how $file is being read: If you read the CGI.pm docs, CGI.pm saves the uploaded file to a temp file and returns $file as a filehandle to that temp file. The docs also say that if you use $file as a scalar, it returns the filename of the original file. Which is why you should be able to pull out the filename to $fileName, and then continue to use $file when you read the file, assuming the filehandle is being created and passed correctly.

question, which may or may not be related: are you accessing this subroutine from within the your module or from outside your module? if from within, how are you calling this function? I'm just wondering why you need to pass the object (i.e. my $self=shift;) if you never need $self. Unless, of course, this is the routine you are accessing from outside the module. It's just that I think that perl writing convention recommends that a subroutine with a name that begins with an underscore (i.e. "_file_upload") indicates an internal routine. Just a convention, though, not a rule. But it may confuse people who are used to the convention, plus I'm just trying to make sure you're not unexpectedly chopping off the first parameter you pass to this routine (depending on how you are calling it).

Doesn't answer your question, but I was hoping to help with the insight.

Replies are listed 'Best First'.
Re: Re: YAF(ile)U(ploading)Q(uestion)
by skazat (Chaplain) on Mar 15, 2001 at 06:07 UTC

    You're right, I'm calling this via inside a OO Perl Module, its a simple wrapper to the DB_File module, but it also does a bunch of other things. This is for a simple web-based database admin screen. Info from a form is sent to a script, that calls this Module kinda like

    my $input = CGI -> new(); my $image = $input -> param('image'); # some more form fields fetched through param()... my $info = new -> JustinDb(); $info ->savethis(-name => 'image', -value => $image);

    the _file_upload() is always internal. This module is one of many, and the module itself 'knows' what kind of form field the info was sent from. Yes I'm tricky :) That part is checking out fine. it looks to see if this particular info is handed to it from a fileupload field, and if it is, saves the file to the $img_dir variable.

    I've been fiddling with this some more, and filenames called 1photo.gif will work, but photo.gif will not work! this is incredibly weird. This is my problem and I'm still scratchin my head.

     

    -justin simoni
    !skazat!