Camilo Lozano III
[PHP] How to upload a file
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;
- Main Download: Simple Upload Demo (6)
- 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.
| Print article | This entry was posted by Camilo III on April 2, 2009 at 4:48 pm, and is filed under Info.Tech, PHP, Web Development. Follow any responses to this post through RSS 2.0. Both comments and pings are currently closed. |
Comments are closed.