Insert Record with Photo Uploads

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
Big Problem I would like the form to be able to write the photo to
database  but inform user if its too large or if they are trying to
upload a different file type other than jpeg or gif. I think the if
and else statement is not correct. Just need extra security.Thank you
for all your help.

$conn = mysql_connect("localhost", "root", "");
$target = "images/";
$target = $target . basename( $_FILES['photo']['name']);
// open the connection
// database to use
$month=$_POST['month'] ;
$day=$_POST['day'] ;
$year=$_POST['year'] ;
//$DOB = $month."-".$day."-".$year;
$DOB = date("m-d-Y");
$aCode=$_POST['aCode'] ;
$ph2=$_POST['ph2'] ;
$ph3=$_POST['ph3'] ;
$Phone = $aCode."-".$ph2."-".$ph3;
$activity = '*'.implode('*',$_POST['activities']).'*';
$network = '*'.implode('*',$_POST['networks']).'*';


// create the SQL statement
$sql = "INSERT INTO testtable
('', '$_POST[firstName]','$_POST[LastName]','$_POST
// execute the SQL statement
if (mysql_query($sql, $conn/*$uploaded_size<350000*/)) {
    move_uploaded_file($_FILES['photo']['tmp_name'], $target);
            echo "The file ". basename( $_FILES['photo']['name']). " has
been uploaded";
echo "Your file is too large.<br>";

Re: Insert Record with Photo Uploads

Quoted text here. Click to load it

The time to check if the file is too large is not after its been
uploaded. And allowing users to pic their own filename is just plain

Quoted text here. Click to load it

You've commented out the file size check - so if the query fails it
will report that the file is too big.


Site Timeline