可能重复:
如何允许用户选择上传文件的位置?
我想让我的用户选择上传文件的位置。如果有人可以帮助我,那就太好了。
uploader.html http://pastebin.com/LQP9jxLH
<div id="main">
<center><h2>File Uploader Beta</h2></center><br />
<center>
<form action="upload.php" method="post" enctype="multipart/form-data">
File: <input type="file" name="filename" />
<input type="submit" value="Upload" />
</form>
</center>
</div>
上传.php http://pastebin.com/CtM1LW13
$folder = "files/";
$HTTP_POST_FILES = "";
if(isset($_FILES['filename']['tmp_name'])) // Check if $_FILES['filename']['tmp_name'] is there
{
if (is_uploaded_file($_FILES['filename']['tmp_name'])) {
if (move_uploaded_file($_FILES['filename']['tmp_name'], $folder.$_FILES['filename']['name'])) {
Echo "Your file has been uploaded! You should probably tell Cody what you uploaded so he can get it in the right place. :)";
} else {
Echo "Haha! You don't have access to do that.";
}
} else {
Echo "Your upload has failed.";
}
}
感谢所有帮助。:)
此外,一旦文件上传,我需要它在页面中生成一个脚本。假设 example.jpg 被上传到 /Cody/Pictures。它会删除
没有找到文件。。
并将其替换为: 文件名:$FileName 下载:任何人都可以这样做吗?可以的话谢谢!