Uploading Files into MySQL

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I am working on a script to upload files into MySQL db.  The following
script uploads to a file system how do I go about uploading the file
into the DB?  Where do I put the SQL statement in the code below?

<form method='POST' enctype="multipart/form-data">
<input type="file" name="myfile">
<input type='submit'>
</form>

<?php
	if (isset($_FILES['myfile']))
       {
		print_r($_FILES['myfile']);	

		//check the file size of the upload
		if ($_FILES['myfile']['size'] > 100000)
               {
		die("File exceeds allowed size.");	
		}
		
               //check for acceptable file types
		$file_ext_allowed = array('jpg', 'gif', 'jpeg');
		
		//retrieve the file extension from the uploaded filename
		$fileext = strtolower(substr($_FILES['myfile']['name'],
						  strrpos($_FILES['myfile']['name'], ".")+1));
		
		if (in_array($fileext, $file_ext_allowed))
               {
		//move the uploaded file to /var/www/
		move_uploaded_file($_FILES['myfile']['tmp_name'],
					"/var/www/".$_FILES['myfile']['name']);
		}
		else
               {
		echo "File type not allowed";	
		}
	}

?>

--
**********************************************************************
The content of this e-mail message and any attachments are
confidential and may be legally privileged, intended solely for the
addressee. If you are not the intended recipient, be advised that any
use, dissemination, distribution, or copying of this e-mail is
strictly prohibited. If you receive this message in error, please
notify the sender immediately by reply email and destroy the message
and its attachments.
*********************************************************************

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux