« PHP��ftruncate()�ؿ� | �ᥤ�� | PHP��tmpfile()�ؿ� »
2007ǯ01��09��
PHP��is_uploaded_file()�ؿ���move_uploaded_file()�ؿ�
is_uploaded_file()�ؿ�
���åץ����ɥե����뤫�ɤ���������å����ޤ���
move_uploaded_file()�ؿ�
���åץ����ɤ��줿�ե��������ꤷ���ѥ��˰�ư���ޤ���
�����ꤷ���ե����뤬Í���ʥ��åץ����ɥե�����Ǥʤ���硢�ޤ��Ͼ�ñ¤µï¿½ï¿½Ä¤ï¿½ï¿½ï¿½Æ¤ï¿½ï¿½Ê¤ï¿½ï¿½ï¿½Ê£ï¿½ï¿½ï¿½ï¿½ï¿½Õ¥ï¿½ï¿½ï¿½ï¿½ï¿½Ì¾ï¿½Ç¥ï¿½ï¿½Ã¥×¤ï¿½ï¿½ï¿½ï¿½ï¿½ç¡¢ï¿½ï¿½Æ°ï¿½ï¿½Î¥Ç¥ï¿½ï¿½ì¥¯ï¿½È¥ï¿½Î¥Ñ¡ï¿½ï¿½ß¥Ã¥ï¿½ï¿½ï¿½ó¤¬½ñ¤¹ï¿½ï¿½ßµï¿½ï¿½Ä¤ï¿½ï¿½ï¿½Æ¤ï¿½ï¿½Ê¤ï¿½ï¿½ï¿½ï¿½Ê¤É¡ï¿½ï¿½ï¿½ï¿½é¤«ï¿½ï¿½ï¿½ï¿½Í³ï¿½Ç°ï¿½Æ°ï¿½Ç¤ï¿½ï¿½Ê¤ï¿½ï¿½ï¿½ï¿½Ë¤ï¿½FALSE���֤��ޤ���
�� PHP�ǥե�����򥢥åץ����ɤ�����ˡ�Υ���ץ�
���ե������ʸ�������ɤ�EUC����¸���Ƥ���������
<?php
//���åץ����ɤ������ν���
if($_POST['mode'] == 'upload'){
if(!is_uploaded_file($_FILES['img1']['tmp_name'])){
die("���顼�����åץ����ɤ��줿�ǡ������ե�����ǤϤ���ޤ���");
}
if($_FILES['img1']['error']){
die("���顼��{$_FILES['img1']['error']}");
}
$filePath = '/var/www/htdocs/images/'.$_FILES['img1']['name']; //�ե�����ΰ�ư������
$res = move_uploaded_file($_FILES['img1']['tmp_name'], $filePath);
if(!$res){
die("���顼���ե�����ΰ�ư�˼��Ԥ��ޤ�����");
}
$result = "���åץ����ɤ�����˴�λ���ޤ�����";
}
print <<<EOF
<html>
<head>
<title>�ե����륢�åץ�����</title>
<meta http-equiv="Content-Type" content="text/html; charset=EUC-JP">
</head>
<body>
$result
<form name="uploadForm" enctype="multipart/form-data" action="{$_SERVER['PHP_SELF']}" method="post">
<input name="img1" type="file"><br>
<br>
<input type="hidden" name="mode" value="upload">
<input type="submit" name="submit" value="���åץ�����">
</form>
</body>
</html>
EOF;
?>
��Ƽ� wing : 2007ǯ01��09�� 23:33