cforms上传中自定义文件名
我真的很喜欢 WordPress 的 cforms 插件。它非常强大,但易于使用。 但今天我却走进了死胡同。
基本上,我需要一个表单来让用户提交他们的名字和姓氏,然后上传两个文件,我需要将其重命名为“A_Firstname.Lastname.ext”和“B_Firstname.Lastname.ext”。分机”。
默认情况下,cforms 只保留上传者的文件名。 如果有人熟悉 cforms 插件,那么任何指南将不胜感激!
提前致谢。
I really like the cforms plugin for wordpress. It's very powerful, yet easy to use.
But today I ran into a dead-end.
Basically I need a form to let users submit their first- and last name, then upload two files, which I need to rename to "A_Firstname.Lastname.ext" and "B_Firstname.Lastname.ext".
By default cforms just leaves the file name as it was by the uploader.
If anyone is familiar with the cforms plugin then any guidelines would be much appreciated!
Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以通过在 my-functions.php 中创建 my_cforms_logic 函数来更改文件名(如果您想了解其工作原理,则从 lib_validate.php 的第 270 行调用 my_cforms_logic)。
示例 my-functions.php 中有一个示例,但将 test_ 添加到给定文件名的开头的更简单的示例如下所示:
因此,如果您能弄清楚如何访问名字和姓氏的值(我怀疑类似 $cformsdata['data']['Firstname'] 的东西会起作用)那么你应该开始做生意了。
菲尔
You can change the filename by creating a my_cforms_logic function in my-functions.php (my_cforms_logic is called from line 270 of lib_validate.php if you want to understand why it works).
There is an example in the sample my-functions.php but even simpler example of adding test_ to the beginning of the given filename would look like this:
So if you can figure how to access the values of the first and last name (I suspect something along the lines of $cformsdata['data']['Firstname'] will work) then you should be in business.
Phil