Hi there, I have a form submitting to a mysql database. It was requested that I put a multiple file upload option on it. So I added the fields to the form and the database and added the upload script to the form processing file (and of course created the folder on the server with proper permissions to upload to). It should upload the file(s) to the folder on the server and insert the filename into the database. I keep getting:
HTTP Error 500 (Internal Server Error): An unexpected condition was encountered while the server was attempting to fulfill the request.
This leads me to believe the upload script isn't working properly. If someone could take a look at it I would be a very happy guy.
This is the upload script: (insert.php)
<?php
$con = mysql_connect("server","user","pass");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("db", $con);
$dateSubmitted = date("Y-m-d");
$target = "attachments/";
$target = $target . basename( $_FILES['doc1']['name']);
$target = $target . basename( $_FILES['doc2']['name']);
$target = $target . basename( $_FILES['doc3']['name']);
$target = $target . basename( $_FILES['doc4']['name']);
$target = $target . basename( $_FILES['doc5']['name']);
$sql="INSERT INTO investments (active, project, inv_amount, account_type, prefix, first_name, last_name, address1, address2, city, province, postal_code, country, phone, email, referral_fee, ref_agent, ship_name, ship_address, ship_city, ship_province, ship_postal, ship_country, notes, dateSubmitted, doc1, doc2, doc3, doc4, doc5)
VALUES
('$_POST[active]','$_POST[account_type]','$_POST[project]','$_POST[inv_amount]','$_POST[prefix]','$_POST[prefix]','$_POST[first_name]','$_POST[last_name]','$_POST[address1]', '$_POST[address2]','$_POST[city]','$_POST[province]','$_POST[postal_code]','$_POST[country]','$_POST[phone]','$_POST[email]','$_POST[referral_fee]','$_POST[ref_agent]','$_POST[ship_name]','$_POST[ship_address]','$_POST[ship_city]','$_POST[ship_province]','$_POST[ship_postal]','$_POST[ship_country]','$_POST[notes]','$_POST[dateSubmitted]',$_FILES['doc1']['name'],$_FILES['doc2']['name'],$_FILES['doc3']['name'],$_FILES['doc4']['name'],$_FILES['doc5']['name'])";
//Writes the photo to the server
if(move_uploaded_file($_FILES['doc1']['tmp_name'], $target))
if(move_uploaded_file($_FILES['doc2']['tmp_name'], $target))
if(move_uploaded_file($_FILES['doc3']['tmp_name'], $target))
if(move_uploaded_file($_FILES['doc4']['tmp_name'], $target))
if(move_uploaded_file($_FILES['doc5']['tmp_name'], $target))
{
//Tells you if its all ok
echo "The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded, and your information has been added to the directory";
}
else {
//Gives and error if its not
echo "Sorry, there was a problem uploading your file.";
}
if (!mysql_query($sql,$con))
{
die('Error: ' . mysql_error());
}
//echo "1 record added";
header("Location: ../forms.php");
mysql_close($con)
?>
Thanks in advance.
JE