ryuozero Site Admin
�������: 13 Jul 2005 �ͺ: 1145
|
�ͺ�����: Mon Apr 20, 2009 5:05 am ����ͧ: |
|
|
ryuozero.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>
<body>
<form action="add_file.php" method="post" enctype="multipart/form-data">
<input name="userfile" type="file" /><br/>
<input name="" type="submit" value="Submit" />
</form>
</body>
</html>
add_file.php
<?
$path = "d:\\";
$max_size = 100000;
$file_allow = array("application/x-zip-compressed", "text/plain","image/bmp", "image/gif", "image/pjpeg","image/jpeg");
function validate_form($file_input,$file_size,$file_type) {
global $max_size,$file_allow;
if ($file_input == "none") {
$error = "����� file ��� Upload";
} elseif ($file_size > $max_size) {
$error = "��Ҵ����Ë���� $Max_File_Size 亵�";
} elseif (!check_type($file_type,$file_allow)) {
$error = "����������� ���͹Øҵ��� Upload";
} else {
$error = false;
}
return $error;
}
function check_type($type_check) {
global $file_allow;
for ($i=0;$i<count($file_allow);$i++) {
if ($file_allow[$i] == $type_check) {
return true;
}
}
return false;
}
$error_msg = validate_form($_FILES["userfile"],$_FILES["userfile"]["size"],$_FILES["userfile"]["type"]);
if ($error_msg) {
echo $error_msg;
} else {
if (!move_uploaded_file($_FILES["userfile"]["tmp_name"],$path."/".$_FILES["userfile"]["name"])) {
echo "��� Upload ���º����";
} else {
echo "��� Upload �ջÑ��";
}
}
?>
code �ش��� compatible ����� 4.1.0 ���仹Ф�Ѻ ���ͧ��������ö��ҹ����͹��Ѻ c&p ����¤�Ѻ |
|