in reply to Upload an image file

Thanks tachyon, that helped some an you explained it very well, but I'm still having problems.

The problem is actually in opening the file to copy. If in the file box of the form I put in /path/to/myfile/on/the/web/server/pic.jpg rather than browse and grab a pic off of the hard drive of my Windows PC (C:\Documents and Settings) to upload to the webserver then it works great. BUt it won't open a file that is local. Any ideas? Do I need to be substituting the spaces in the windows file name first in order for it to be opened?

Replies are listed 'Best First'.
Re: Upload an image file
by Abigail (Deacon) on Jul 06, 2001 at 02:30 UTC
    Eh, are you running the program on a different machine than where the file actually resides? That's not going to work. Unless you NFS mount the remove disk or so. Or use tied file handles. But it's unlikely either the remote or the local machine are set up that way.

    Why not use the file upload routines from CGI.pm?

    -- Abigail

      Yes, the script and location that I want to put the files are on the webserver. I am running the script from my own pc.

      What can be done with file handles?

      BY upload routine I assume you mean something like:
      my $file_handle = $req->upload( $file );

      I have tried various ways and get errors with some. I think that I got that one to work eventually, sort of, since the file size still was 0.
        Now I am utterly confused. You run the script on your own PC? Why are you using CGI then? Are you really, really sure you run the script on your PC? Pointing your browser to a URL that causes the script to run on the webserver doesn't make your script run on your PC. It still runs on the webserver.

        With upload routine, I mean what's discussed in the CGI manual page:

        $filename = $query -> param ('uploaded_file'); while (<$filename>) {print}
        with the appropriate name from the form of course.

        -- Abigail

Re: Re: Upload an image file
by Anonymous Monk on Jul 06, 2001 at 02:13 UTC
    Here is what was in the error log:

    Could not read C:\sailboat.jpg, No such file or directory at /the/path/of/the/cgi/script.cgi line 336. Database handle destroyed without explicit disconnect.

    Please help!!!!