<html>
<head>
<title>Main Page</title>
</head>
<body>
<h2>Main Page</h2>
<form method="post" action="index.php" enctype="multipart/form-data">
<input type="file" name="filename">
<input type="hidden" name="MAX_FILE_SIZE" value="102400"/>
<input type="submit" value="Upload file">
<br>
<?php
echo $_FILES['filename']['name'];
$uploads_dir = '/uploads';
$tmp_name = $_FILES['filename']['tmp_name'][$key];
$name = $_FILES['filename']['name'][$key];
move_uploaded_file($tmp_name, "$uploads_dir/$name");
?>
</body>
</html>
如何將此文件移動到文件夾? 我嘗試使用move_uploaded_file 但downst移動...(如何將文件移動到另一個文件夾?
不應該'回聲$文件名;'是'回聲$ _ POST [ 「文件名」];'? – andrewsi 2012-07-13 16:17:05
你看過手冊嗎? http://www.php.net/manual/en/features.file-upload.post-method.php – mario 2012-07-13 16:19:36
[在PHP中獲取發佈的文件名]的可能重複(http://stackoverflow.com/questions/10940620/get ( – mario 2012-07-13 16:20:22