だから私はすでにそこにあったいくつかのコードを編集しています.PDF以外のファイルをアップロードできるように追加の拡張機能を追加する方法がわかりません.手がかりはありますか? jpeg、docx、doc、xls、wpsを追加したいです。
<?php
$lastname=$_POST['mylastname'];
$firstname=$_POST['myfirstname'];
$asuid=$_POST['#'];
$ftype=$_POST['ftype'];
$dkServerConn = mysql_connect("#", "#", "#") or die("no way");
mysql_select_db("#", $dkServerConn) or die("Cannot connect to the DB!");
$sql1 = "SELECT * FROM scholnumber";
$dkResultSet1 = mysql_query($sql1,$dkServerConn) or die(mysql_error());
$checkIt=0;
while ($dkROWrecord1 = mysql_fetch_array($dkResultSet1,MYSQL_BOTH))
{
$checkIt=$dkROWrecord1['filenumber'];
}
$checkIt2=$checkIt+1;
$sql2="Update scholnumber set filenumber='".$checkIt2."'";
$dkResultSet2 = mysql_query($sql2,$dkServerConn) or die(mysql_error());
echo "<html>
<head>
<title>Uploading Information</title>
<style> body { font-family:arial; font-size:14px } </style>
</head>
<body><table cellpadding='5' align='center' width='55%'><tr><td><p> </p>
<img src='#'><br />
<img src='#'><br />
<span style='font-family:arial;font-size:14pt'> 2013-2014 Privately Funded Scholarship Application</span>
<h3><br/>";
// File validation -->
$allowedExts = array("pdf","docx","doc","wps");
$extension = end(explode(".", $_FILES["file"]["name"]));
if (($_FILES["file"]["type"] == "application/pdf")
&& in_array($extension, $allowedExts)){
if ($_FILES["file"]["error"] > 0){
echo "Return Code: " . $_FILES["file"]["error"] . "<br>";
}
else{
echo "<p />Submission successful.<p />
Your submission has been received. If you have loaded all of your documents, you can close this browser. Your scholarship application is complete.<p />";
echo "Upload: " . $_FILES["file"]["name"] . "<br>";
echo "Type: " . $_FILES["file"]["type"] . "<br>";
if (file_exists("upload/" . $_FILES["file"]["name"])){
echo $_FILES["file"]["name"] . " already exists. ";
}
else{
$ext = substr($_FILES['file']['name'], strpos($_FILES['file']['name'],'.'), strlen($_FILES['file']['name'])-1);
$docName = $checkIt.$ext;
move_uploaded_file($_FILES["file"]["tmp_name"],"upload/" . $docName);
// echo "Stored in: " . "upload/" . $_FILES["file"]["name"];
}
}
}
elseif($_FILES["file"]["type"] == "application/pdf"){
}
else{
echo "<hr> <p /> >>>>>> INVALID FILE <<<<<<<< <p /> <p />";
}
// End of the validation
$sql3="insert into scholfile (filename, lastname, firstname, asuid, ftype) values ('$checkIt', '$lastname', '$firstname', '$asuid', '$ftype')";
$dkResultSet3 = mysql_query($sql3,$dkServerConn) or die(mysql_error());
$sql6="select * from scholarships where asuid='".$asuid."'";
$dkResultSet6 = mysql_query($sql6,$dkServerConn) or die(mysql_error());
while ($dkROWrecord6 = mysql_fetch_array($dkResultSet6,MYSQL_BOTH))
{
$email=$dkROWrecord6['email'];
}
$from="Scholarships";
$fromem="scholarships@#.edu";
$subjectStudent = "Thank you for your supporting documentation.";
$messageStudent="Hello, ".$firstname. " -<p />
We have received your ".$ftype.". <p />
<hr />
If you have any questions, please contact the Financial Aid and Scholarships Office at 870-972-2310 or reply to this email.
<p />
Thank you for your submission.<br />Financial Aid and Scholarships Office";
//Email Information
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
$headers .= "To:" .$firstname. "<" . $email. ">\r\n";
$headers .= "From:" . $from . "<". $fromem . ">\r\n";
mail($email, $subjectStudent, $messageStudent, $headers);
?>
<p /> <p />
If you have another document to submit, please <a href='fileupload.php'>click here.</a><p />
Thank you!<p /></body></html>