in reply to Re: Uploading Files (Win32)
in thread Uploading Files (Win32)

I have changed my code to the following and I am still getting the same result i.e. the contents of the file are not read! Here is the code I am using:

use CGI qw/:all/; my $form = new CGI; print $form->header; my $filehandle = $form->upload('UPLOADFILE'); print "<br>Contents of file:<br><pre>"; while (<$filehandle>){ print ;} print "</pre></body></html>";

I'm very new to PERL but the problem seems to be that the filehandle for the local file (i.e. the file to be uploaded) is not pointing to the local file for some strange reason. If I use the 'open' command to read the contents of the local file then I get an error saying "no such file or directly". Is this problem something to do with paths and forward and back slashes>

Any more help would be appreciated

Eoin

Replies are listed 'Best First'.
Re: Re: Re: Uploading Files (Win32)
by helgi (Hermit) on Feb 06, 2003 at 16:24 UTC
    Is this problem something to do with paths and forward and back slashes?

    Almost certainly.

    Use the full path.

    Use forward slashes / There is NO need to use backward slashes ever under Windows unless you specifically want to work through the cmd.exe or command.com shells (you don't).

    Your current working directory os almost certainly NOT what you think it is which is probably causing the problem.

    You don't show how you are opening the external file for writing. Try something like (untested):

    my $dir = 'C:/temp/web'; # or something like that my $localfile = "$dir/$filename"; open OUT, ">", $localfile or die "Cannot open $localfile for writing:$ +!\n";
    --
    Regards,
    Helgi Briem
    helgi AT decode DOT is

      Helgi

      Thanks for the response(s) - I appreciate you taking the time to help a novice

      The following lines of code better illustrate the problem:

      my $input_filehandle = upload( 'UPLOADFILE' ); sysopen(IN, $input_filehandle, O_RDONLY) || Error ('open','file'); sub Error { print "The server can't $_[0] the $_[1]: $! \n"; exit; }

      The above code returns the following error:

      "The server can't open the file: No such file or directory"

      Which (I think) means the program can't find the local file for reading?

      I'll use the code you posted to try and debug a little further!

      Thanks

      Eoin