Archive

Posts Tagged ‘file’

Creating A File Upload Script

April 28th, 2009 Ahsun Taquveem Chohan 1 comment

I will teach you how to create a basic script that allow people to upload files and stores details of their uploads in a database. Follow up, it is not hard at all…. If you have questions, feel free to ask

First we need to create the database table with the following SQL:

 

CREATE TABLE `uploads` (
`id` int(10) unsigned NOT NULL auto_increment,
`whenuploaded` datetime NOT NULL default '0000-00-00 00:00:00',
`ipaddress` varchar(15) NOT NULL default 'unknown',
`imageloc` varchar(255) NOT NULL default 'unknown',
`imagesize` int(10) unsigned default NULL,
`imagetype` varchar(30) default NULL,
PRIMARY KEY (`id`)
) TYPE=MyISAM;

 

Then here’s the PHP code you need at the top of the page where you’re going to have your upload form. You need to change the database access details at the top and the ‘defines’ to specify your domain and path names. Create the DEST_DIR directory on the server with 777 permissions.

Read more…