PHP Scripts and Classes

Upload any file using a PHP Script

This PHP upload class (the old name) can be used to upload files with a client browser to a remote web server location. The features in the first release are: file-extension check, maximum file- size limitation and a flexible error reporting system. The class is extremely easy to use and comes together with full working examples. Since the second version is it possible to upload multiple files. Check the class file for all update information. The version 2.22 (and higher) is compatible with the PHP directive "register_globals=off". NEW functions for the multiple upload function: rename files and filename validation. With the updated (version 2.25) photo upload extension it's possible to upload photos (logos) and resize them to the maximum X and Y size. Since version 2.26 the is support for the ImageMagick command line tools as an option (works faster then functions of the GD library). Note the database example since the last version.

PHP Script Download - All update information

Visit here Script Demo - Post here your questions and suggestions.

Last changes and updates:

  • Version 2.33
    In this version it's possible to validate files by their native mime type. If you add the $the_mime_type into your upload script, the mime type will be checked otherwise not. We added in the main class file an array with the most important mime types and also the internal mime type variable. The method named validateMimeType() is new and the method validateExtension() is changed. Add also the new message no. 18 to the method error_text(). The basic example file is changed to use the new feature.
  • Version 2.32
    Added vars for file and directory permissions, check also the methods move_upload() and check_dir().
    Method get_uploaded_file_info(): Replaced old \n line-ends with the PHP constant variable PHP_EOL.
    Method create_file_field(): Minor code clean up (better code formatting and replaced double with single quotes)
    Method error_text(): Older Dutch language messages are re-written, thanks Julian A. de Marchi. Added HTTP error messages (error 6-7 introduced with newer PHP versions, error no. 5 doesn't exists).
  • Version 2.31
    If someone use more then one file upload at the same time while using the rename option there was a problem with the new name. The PHP function "sleep" take care about unique filen names. I added a new method that outputs some html code which I often use if the file name is stored in a database. If there is a name defined as an argument the file field is replaced with a regular text field, note the new example file "upload_db_example.php".