Simple Upload
Below is a simple file upload script. It has a dual purpose, something easy to install for those who can use it and something to study for those who want to see how it's done.
Within the script itself, you specify:
-
Where the uploaded file is stored (may be blank to store in the same directory where the script is installed).
-
The file name (optional).
-
The URL of a "thank you" page (also optional).
Do all edits with an ASCII/plain text word processor like NotePad or TextWrangler.
Here is the script:
To install the script:
-
Make any edits you wish to make.
-
Upload the script into a directory on your server that can run Perl CGI scripts. Upload with FTP as a plain text file, not as a binary file.
-
Give the script 755 permissions.
To use, type the URL of the script into your browser. The script will generate its own upload form.
If you wish to put an upload form on a web page you create, let the script generate the form, then copy the source code and paste it into your web page. Easy, huh?
More than one copy of the script may be installed, either by by naming each copy differently or installing in separate directories.
For web developers, this may be just the ticket for clients to use when they wish to update an image or other file on a regular basis without calling you every time.
Or, use it for yourself. It's probably the easiest upload process around.
For those who wish to have more sophistication, consider letting The Upload Pal do the job for you.
If you're interested in studying how the upload is done, you'll find the script well commented.
The actual uploading and storing of the uploaded file is only about a dozen working lines.
Question:
Did you find this article interesting and understandable? How can it be improved?
Your response is anonymous.
When done typing, click anywhere outside the box. [more info]
Will Bontrager
©Copyright 2007 Bontrager Connection, LLC Bontrager Connection, LLC
Please note:
Articles on this website are presented "as is". However -
If you have a question about a CGI script, HTML, CSS, PHP, or JavaScript
Ask one of our Experts and you'll have your answer!
Click here for details.