通过修改html设置默认文件名/目录,以在Web表单上载 [英] Set a default file name/directory for upload on web form by modifying the html
本文介绍了通过修改html设置默认文件名/目录,以在Web表单上载的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我一直使用此上传表单,每次都使用相同的文件名.我想知道是否有一种方法可以通过更改代码并在本地保存文件来设置表单中的文件名.如果还有其他方法可以自动执行此操作,我也会对此开放.谢谢.
I use this upload form all of the time and use the same file name each time. I wonder if there is a way to set the file name in a form by changing the code and saving the file locally. If there other ways to automate this I'd be open to that too. Thanks.
以下是来源:
<html>
<body>
<form enctype="multipart/form-data" action="mibdata.php" method="POST">
<input type="hidden" name="MAX_FILE_SIZE" value="10000000" />
Choose a file to upload: <input name="uploadedfile" type="file"/><br />
<input type="submit" value="Upload File" />
</body>
</html>
推荐答案
PHP代码:(在mibdata.php中)
PHP Code: (in mibdata.php)
$target_path = "/path/to/save/file/filename.ext";
if(isset($_FILES['uploadedfile'])){
move_uploaded_file($_FILES['uploadedfile']['tmp_name'],$target_path);
}
确保target_path可被服务器写入.
Make sure that the target_path is writable by server.
这篇关于通过修改html设置默认文件名/目录,以在Web表单上载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文