html表单代码如下所示:
Last Name:
Class Notes:
php上传文件及重命名文件代码如下:
define ("FILEREPOSITORY","./");
if (is_uploaded_file($_FILES['classnotes']['tmp_name'])) {
if ($_FILES['classnotes']['type'] != "application/pdf") {
echo "
Class notes must be uploaded in PDF format.
";} else {
/* http://www.manongjc.com/article/1391.html */
$name = $_POST['name'];
$result = move_uploaded_file($_FILES['classnotes']['tmp_name'], FILEREPOSITORY."/$name.pdf");
if ($result == 1) echo "
File successfully uploaded.
";else echo "
There was a problem uploading the file.
";} #endIF
} #endIF
?>