참고한곳.
http://www.w3schools.com/php/php_file_upload.asp
upload 받는 php 파일.
Code Type : PHP
0)
{
echo "Return Code: " . $_FILES["file"]["error"] . "
";
}
else
{
echo "Upload: " . $_FILES["file"]["name"] . "
";
echo "Type: " . $_FILES["file"]["type"] . "
";
echo "Size: " . ($_FILES["file"]["size"] / 1024) . " kB
";
echo "Temp file: " . $_FILES["file"]["tmp_name"] . "
";
if (file_exists("uploads/" . $_FILES["file"]["name"]))
{
echo $_FILES["file"]["name"] . " already exists. ";
}
else
{
move_uploaded_file($_FILES["file"]["tmp_name"], "uploads/" . $_FILES["file"]["name"]);
echo "Stored in: " . "uploads/" . $_FILES["file"]["name"];
if (file_exists("uploads/" . $_FILES["file"]["name"]))
{
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename='.basename("uploads/" . $_FILES["file"]["name"]));
header('Content-Transfer-Encoding: binary');
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Pragma: public');
header('Content-Length: ' . filesize("uploads/" . $_FILES["file"]["name"]));
ob_clean();
flush();
readfile("uploads/" . $_FILES["file"]["name"]);
exit;
}
}
}
}
else
{
echo "Invalid file";
}
?>
...