in reply to Re^3: Upload file (PDB format ) on server
in thread Upload file (PDB format ) on server

thnx Carion....
I suppose Im still not clear about my problem: Here's know the details
---------------------
I want to read a file in PDB format from client by this code by using "POST"
index.pl goes like this and calls results.pl

<form action=results.pl method=post>
<input name=t type=file />
<input type=submit name=t
value=Run />

Now the file whose path is passed to results.pl by the form above, is to be opened and analysed on server.
What to include in index.pl to open the file from client on the server?

  • Comment on Re^4: Upload file (PDB format ) on server

Replies are listed 'Best First'.
Re^5: Upload file (PDB format ) on server
by Corion (Patriarch) on May 28, 2009 at 10:27 UTC

    Have you read the documentation of the CGI module which I linked to before? It handles the reading of POST parameters for you and gives you a nice, convenient file handle to read the uploaded file data from. I recommend searching the documentation for creating a file upload field. Note that you don't need to use the output methods of CGI and can still produce the HTML using print. But reading the uploaded data would likely be done by:

    use CGI ''; my $q = CGI->new(); my $uploaded_file = $q->param('t'); # "t" is the name of the upload fi +eld; ...

    But looking at your posted HTML code, it makes no sense - you use the name t for both, the uploaded file and also for the submit button. While that's possible, it makes things harder than neccessary. Change one of the two to a different name.

Re^5: Upload file (PDB format ) on server
by scorpio17 (Canon) on May 28, 2009 at 15:24 UTC

    Your form tag should look something like this:

    <form enctype="multipart/form-data" action="results.pl" method="post">

    That's probably not your only problem - but you'll need the enctype stuff to upload a file properly.

    Also - you seem a little unclear about how CGI works. A CGI script runs on the SERVER. Your browser runs on the CLIENT. If you're running your own web server, "localhost", then client and server are the same - but that's normally not the case. The scripts don't run as you (i.e., not as your user id), but instead as the web server's user id (usually 'nobody' or 'www-user'). In general, a script running on the server has no way to see files on your local (client) file system, and even if it could, it would not have permission to do anything to them (giving the web server user the ability to do so is a huge security risk - don't do it!).

    The way to do it correctly is upload the file (from client to server). The server will need a directory that it has permission to write into, so it can save the upload. Then you can process it however you like.

      hey scorpio17 that was of real real help.
      I was not clear about the concepts.....n that was what i was requiring. THANKs