Return to Snippet

Revision: 6170
at May 2, 2008 17:58 by iTony

Initial Code
//if they DID upload a file...
	//if no errors...
		//now is the time to modify the future file name and validate the file
		$new_file_name = strtolower($_FILES['photo']['tmp_name']); //rename file
		if($_FILES['photo']['size'] > (1024000)) //can't be larger than 1 MB
			$valid_file = false;
			$message = 'Oops!  Your file\'s size is to large.';
		//if the file has passed the test
			//move it to where we want it to be
			move_uploaded_file($_FILES['photo']['tmp_name'], 'uploads/'.$new_file_name);
			$message = 'Congratulations!  Your file was accepted.';
	//if there is an error...
		//set that to be the returned message
		$message = 'Ooops!  Your upload triggered the following error:  '.$_FILES['photo']['error'];

//you get the following information for each file:

Initial URL

Initial Description

Initial Title
php uploading files

Initial Tags
php, file, files

Initial Language