Home > Info.Tech, PHP, Web Development > [PHP] How to upload a file

[PHP] How to upload a file

April 2nd, 2009

I would like to share this script to all since most of my friends ask how to create an upload script using PHP.

Download the PHP script at;

  1. Main Download: Simple Upload Demo (8)
  2. Mirror 1: simple_upload.zip

Upload File Demo: http://www.cable21.net/camilord/simple_upload/index.html

Modification according to your preferred setup

Its default upload directory is uploads/ and to change this, just change the line 19;

// set upload destination
$uploaddir = “uploads/”;

In the script, it is capable to validate allowed file types. As default, images files are only allowed to be uploaded. To change this, just edit the upload.php at line 37.

// allowed file types
$validMIME = array(‘jpg’,‘jpeg’,‘bmp’,‘png’,‘gif’);

Just add any file extension you want to allow… Sample;

// allowed file types
$validMIME = array(‘jpg’,‘jpeg’,‘bmp’,‘png’,‘gif’,‘doc’,‘zip’,‘pdf’);

So I just allowed Document, Zip and PDF files…

That’s all.. I think everything is understandable.. hehehe.. Please read also the comments.

Camilo III Info.Tech, PHP, Web Development , , , , , ,

Comments are closed.