(mm) Perl CGI to upload files via web browser
Home | Software | Count
Software:
GWT
  GWTOAuthLogin
X/Motif
  ansi xterm
  grabc
  mdgclock
  miv
  mplaymidi
  mppp
  mxascii
  mcmap
  mxcmap
  mxconsole
  mxkill
  mxshowfont
  qtip
  xmastm
  yrolo
Web
  mhttpd
  web counter
  upload.pl
  TimeTrack.pl
  mod_auth_ldap
Games
  fltkmm
  iphonemm
Java
   cdcl
   cdclgwt
   jdgclock
Libraries
  libcalen
  libmcfg
  libsll
  libmsock
Misc
  bangla font
  dpr
  genmake
  hod
  smtp.pl
  vhtml
  phones_ldap
  showpic_ldap
  mbasecalc
  fluid_hack
  kdialppp
  strip2csv
  googlecode-upload
MS Windows
  mwinclip.pl
  mbasecalc
  mailsend
  wiv
upload.pl
(For Unix/Linux/MS Windows)
Upload files with your browser

Updated: Mar-28-2004

upload.pl is simple perl CGI script to upload file using netscape 2.0+ or Internet Explorer 4.0+. The program uses the excellent CGI.pm perl module (part of standard perl now). To upload a file, the user must validate herself. The script uses a text file as a user database. The text file contains the vertical bar separated userid, Unix crypted password ( can be used in Windows as well) and user's upload path.

How to use

  1. Download:
    Source
    File: upload.txt
    Size: 12789 bytes
    MD5 Checksum: 4da435708e3d9801688148a551f5fc11
    Last updated: Mar-28-2004

  2. rename it to upload.pl, mv upload.txt upload.pl (in Unix)

  3. Check the first line of the script upload.pl, and make sure it points to the correct path of perl. For MS Windows, it might look like: #!c:\perl\bin\perl

  4. chmod 755 upload.pl
    (To make the script executable in Unix)

  5. Copy upload.pl to your cgi-bin directory or where ever you keep CGI programs. Read about common problems related to CGI scripts in WWW FAQ.

  6. Look at the script upload.pl. If needed, edit the variables: $g_upload_db, $g_overwrite. The variable $g_upload_db specified the path of the authentication text file. The variable $g_overwrite specifies if the existing file will be over-written or not. The default is to overwrite.

  7. if you want to restrict upload to files with certain extentions, change the value of $g_restrict_by_ext to 1 and ALSO modify the @g_allowed_ext if you want to add other allowable extensions.

  8. If you want to restrict upload file size (in bytes) uncomment the line $CGI::POST_MAX=50000; at the top of the script and change the number 50000.

  9. Create the text file for authentication, the name and path is specified by the variable $g_upload_db. The format of the text file is as follows:
        user_id|Unix_crypted_password|path_of_upload_for_this_user_id
        
    For example:
    
        muquit|hudu987cmJhQ7|/usr/local/web/upload/muquit
        foo|uiDU9kdfhwq5t|/usr/local/web/upload/foo
        joe|idkfdi87adi6g|upload/joe
    
    
    In Windows, the file might look like:
    
    
        muquit|kjdu987cmJhQ7|c:/upload/muquit
        foo|o0DU9kdfhwq5t|d:/upload/foo
    
    
    
    The directory for the users must be created by the administrator. The web server must be able to write to these directories. You can use the script
    Source
    File: mcrypt.txt
    Size: 824 bytes
    MD5 Checksum: 35ab0bbfa0090a3127099b954d11dffc
    Last updated: Jun-12-1999

    to create the crypted password or you just can cut and paste from /etc/passwd file (not recommended). Or install the CGI script

    Source
    File: mcryptcgi.txt
    Size: 4427 bytes
    MD5 Checksum: 9a02a22d78390e90be6dbd5fdb79c357
    Last updated: Nov-29-2000
    .

  10. Access the script: http://web_server/cgi-bin/upload.pl

  11. That's all folks!
If you use this script, Please let me know as well. I tested this script on Linux and MS NT 4.0 and MS Windows 2000.

Screenshot

Copyright
Freeware. Do whatever you like with it. It would be nice but not required if you give me the credit for it.

THIS PROGRAM IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY. THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL THE AUTHOR Muhammad A. Muquit BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTUOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

ChangeLog

  • Write more desriptive error messages.
  • Handle CR at the end of db file. It can happen if someone is ftp's to a Windows machine.
    (Mar-28-2004)

  • Upload can be restricted by size or file extention.
    (May-04-2003)

  • The format of the upload.db file is changed, now the userid, Unix crypted password and upload path are separated by a vertical bar instead of colon.
    (Sep-30-2000)

  • James Bee, JamesBee@home.com, reported that from Windows filename such as c:\foo\fille.x remains as c:\foo\file.x, Fixed, Jul-22-1999.

URL of this page: http://www.muquit.com/muquit/software/upload_pl/upload_pl.html

back Page updated: Sun Mar 31 01:59:56 2013 GMT   Copyright © 2013 muquit@muquit.com.