Forum Moderators: open

Message Too Old, No Replies

Uploading a file

What to do next?

         

fashezee

8:39 pm on Oct 30, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I would like to enable users to upload their files to a specific directory.
I have included on my web page the following:

<input type="file" name="image">

What action should I put in FORM tag so that the file the client selected
will be saved in the respective directory?

dingman

8:46 pm on Oct 30, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I'm pretty sure you'd need to use a server-side script of some type to handle that form no matter what. (IE, something written in PHP, Perl, or the like.) The details of how that script should be written will depend on the language you are using and possibly the configuration of your server.

madcat

8:58 pm on Oct 30, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



fashezee- look at at PHP Fast & Easy Web Development by Julie Meloni- Chapter 10 is all about it.

vbull

9:21 pm on Oct 30, 2002 (gmt 0)

10+ Year Member



I think you actually need some software (or complex scripting) to upload the file from the client to the server. Once you have it in a directory you can email it, publish to your page etc.

andreasfriedrich

12:07 am on Oct 31, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



complex scripting

Actually just a couple of lines of code will suffice in both Perl [search.cpan.org] and PHP [php.net].

$fh = $query->upload('name_of_file_upload_field'); 
while (<$fh>) {
print;
}

will print an uploaded file in Perl using Lincoln Steinīs CGI module [search.cpan.org].

Andreas