wordpress表单调用_如何在WordPress中创建文件上传表单

wordpress表单调用

Do you need to have your website visitors upload files on your contact form?

您是否需要让网站访问者在您的联系表上上传文件?

Maybe you’re hiring employees and want to collect resumes, or perhaps you’re running another application form or photography contest where you need the applicant to attach files.

也许您正在招聘员工并想收集简历,或者您正在运行其他申请表或摄影比赛,您需要申请人附加文件。

In this tutorial, we’ll show you how to create a file upload form in WordPress (step by step).

在本教程中,我们将向您展示如何在WordPress中创建文件上传表单(逐步操作)。

How to create a file upload form in WordPress
为什么要在WordPress中创建文件上传表单? (Why Create a File Upload Form in WordPress?)

If you want to collect any kind of file from your users, then a file upload form is a great idea. You could let users upload images, PDF files, Word documents, or other types of files.

如果您想从用户那里收集任何类型的文件,那么文件上传表单是个好主意。 您可以让用户上载图像,PDF文件,Word文档或其他类型的文件。

Using a file upload form makes life easy for you, and your users.

使用文件上传表单使您和您的用户生活变得轻松。

Instead of the email back-and-forth, you can create a form that include all the fields you need, so you can collect all information at once.

您可以创建一个包含所需所有字段的表单,而不必来回发送电子邮件,从而可以一次收集所有信息。

Also, your form should automatically save the form data in your WordPress database. That way, you can easily find the submissions, even if you miss or delete an email.

另外,您的表单应自动将表单数据保存在WordPress数据库中 。 这样,即使您错过或删除电子邮件,也可以轻松找到提交的内容。

影片教学 (Video Tutorial)

演示地址

If you’d prefer written instructions, just keep reading.

如果您喜欢书面说明,请继续阅读。

如何在WordPress中创建文件上传表单 (How to Create a File Upload Form in WordPress)

For this tutorial, we’ll be using WPForms, which is the best contact form plugin for WordPress.

在本教程中,我们将使用WPForms ,它是WordPress最佳联系表单插件

If you’re on a tight budget, you can get the file upload feature on WPForms’ Basic plan. However, the fully-featured Pro plan gives you access to bonus form templates, survey reports, and tons of other powerful features.

如果预算紧张,可以在WPForms的基本计划中获得文件上传功能。 但是,功能全面的Pro计划使您可以访问奖金表格模板,调查报告以及大量其他强大功能。

First, you’ll need to install and activate the WPForms plugin. If you’re not sure how, just check out our step by step guide on how to install a WordPress plugin.

首先,您需要安装并激活WPForms插件。 如果您不确定如何安装,请查看有关如何安装WordPress插件的分步指南。

Once you’ve activated the plugin, you’ll see a new WPForms tab in your dashboard.

激活插件后,您将在仪表板上看到一个新的WPForms选项卡。

Go to the WPForms » Addons page and scroll down to the Form Templates Pack Addon. Click on the ‘Install Addon’ button to install and activate it.

转到WPForms»插件页面,然后向下滚动到“表单模板包插件”。 单击“安装附件”按钮以安装并激活它。

Installing the WPForms form template pack addon

You are now ready to create your first file upload form.

现在您可以创建您的第一个文件上传表单。

Head over to the WPForms » Add New page.

转到WPForms»添加新页面。

Creating a new form using WPForms

You’ll be taken straight to the WPForms builder. You can give your form a name at the top of the screen:

您将直接进入WPForms构建器。 您可以在屏幕顶部为表单命名:

Giving your form a name in WPForms

You’ll also need to choose a template. We recommend using the File Upload Template, which you can find in the Additional Templates section. Click on the template to use it.

您还需要选择一个模板。 我们建议您使用“文件上传模板”,您可以在“其他模板”部分中找到该模板。 单击模板以使用它。

The File Upload Form will automatically be created for you.

文件上传表格将自动为您创建。

The default file upload form, created from the template

You can use the file upload form without making any changes at all, if you want.

如果需要,您可以使用文件上传表单,而无需进行任何更改。

By default, it’ll allow users to upload the following file types:

默认情况下,它将允许用户上传以下文件类型:

  • Images files: .png, .gif, .jpg

    图像文件:.png,.gif,.jpg
  • Documents: .doc, .xls, .ppt, .pdf

    文件:.doc,.xls,.ppt,.pdf
  • Audio: .wav, .mp3, .mp4

    音频:.wav,.mp3,.mp4
  • Video: .mpg, .mov, .wmv

    视频:.mpg,.mov,.wmv

If you’d like to restrict the file types further, click on the File Upload field to edit it. You’ll see the Field Options on the left hand side of your screen:

如果您想进一步限制文件类型,请单击“文件上传”字段进行编辑。 您将在屏幕左侧看到“字段选项”:

Editing the file upload field in WPForms

In the Allowed File Extensions box, you can type in whatever file formats you want to accept. We’re going to allow the image formats .png, .gif, and .jpg. Make sure you separate them with a comma.

在“允许的文件扩展名”框中,您可以键入要接受的任何文件格式。 我们将允许图像格式为.png,.gif和.jpg。 确保用逗号分隔它们。

Enter the file types that you want to allow users to upload

Note: WordPress limits the types of files that can be uploaded to the site for WordPress security reasons. You can add additional file types to WordPress if you want to allow users to upload file types that aren’t normally allowed.

注意:出于WordPress安全的原因,WordPress限制了可以上传到站点的文件类型。 如果要允许用户上传通常不允许的文件类型,则可以向WordPress添加其他文件类型

You can also set a maximum file size and a maximum number of files. For our competition, we’re going to allow people to submit up to 3 photos of up to 50MB each.

您还可以设置最大文件大小和最大文件数。 对于我们的比赛,我们将允许人们最多提交3张照片,每张照片最大50MB。

If you want to prevent people from submitting the form without attaching their file(s), you can check the Required box. This means the form can’t be submitted unless at least 1 file has been uploaded.

如果要阻止人们提交表单而不附加他们的文件,则可以选中必填框。 这意味着除非至少上传了一个文件,否则无法提交表单。

The edited file upload field on our form

By default, the File Upload Field uses a modern format that lets users drag and drop their files. However, if you have limited space for your form, or you prefer a classic upload field, you can change this.

默认情况下,“文件上载字段”使用现代格式,允许用户拖放文件。 但是,如果您的表单空间有限,或者您更喜欢经典的上载字段,则可以更改此设置。

Simply click on ‘Advanced Options’ to open up more options for the field. You can then switch the style from Modern to Classic using the dropdown.

只需单击“高级选项”以打开该字段的更多选项。 然后,您可以使用下拉菜单将样式从现代切换为经典。

Editing the advanced options for the file upload field

Tip: The classic upload field only allows one file to be uploaded. If you want users to be able to submit more than one file, you’ll need to add more than one File Upload Field to your form.

提示:经典上传字段仅允许上传一个文件。 如果希望用户能够提交多个文件,则需要在表单中添加多个“文件上载字段”。

You can also choose to store the submitted files in the WordPress Media Library, if you want. This makes it easy for you to add them to a post or page. For instance, with our photography competition, we might include the best photos when we announce the winner.

如果需要,您还可以选择将提交的文件存储在WordPress媒体库中 。 这使您可以轻松地将它们添加到帖子或页面中。 例如,在我们的摄影比赛中,当我们宣布获奖者时,我们可能会包括最佳照片。

Note: The uploaded files are still saved in your WordPress database, even if you don’t check this box. They’re just stored in a separate folder in your WordPress hosting account.

注意:即使您未选中此框,上传的文件仍会保存在WordPress数据库中。 它们只是存储在WordPress托管帐户的单独文件夹中。

If you want to edit any of the other fields on your form, you can click to edit them on the left hand side in the same way.

如果要编辑表单上的任何其他字段,可以单击以相同的方式在左侧编辑它们。

You can also add new fields using the Add Fields tab. Simply drag and drop any field that you want to add to your form.

您也可以使用“添加字段”选项卡添加新字段。 只需将要添加到表单的任何字段拖放。

Here, we’ve added a Website/URL field to the form, so that photographers can give us the link to their website.

在这里,我们在表单中添加了“网站/ URL”字段,以便摄影师可以给我们提供其网站的链接。

Adding a website / URL field to the form

If you want to remove a field, hover your mouse cursor over it and click the red trash can icon. We’re going to remove the Phone field as we don’t need the photographers’ phone numbers.

如果要删除字段,请将鼠标光标悬停在该字段上,然后单击红色的垃圾桶图标。 我们将删除“电话”字段,因为我们不需要摄影师的电话号码。

Deleting the phone field from the form

Once you’re happy with your form, click the Save button at the top of the screen.

对表单满意后,单击屏幕顶部的“保存”按钮。

Click the Save button in WPForms
设置文件上传表单的通知 (Setting Up Your File Upload Form’s Notifications)

Under the Settings tab, you can click Notifications to set up your form’s email notifications. You may want to change the default settings.

在“设置”选项卡下,您可以单击“通知”来设置表单的电子邮件通知。 您可能需要更改默认设置。

By default, the form sends an email notification to {admin_email}.

默认情况下,该表单将电子邮件通知发送到{admin_email}。

If you created your WordPress site by yourself, then this will be your email address. If not, then you can delete {admin_email} and type your own email address here instead.

如果您自己创建了WordPress网站 ,那么这就是您的电子邮件地址。 如果不是,那么您可以删除{admin_email}并在此处键入您自己的电子邮件地址。

Changing the email address that the form notifications are sent to

Tip: Not sure if {admin_email} is your email address or not? Go to Settings » General in your WordPress dashboard. Look for the Administration Email Address. You can change it here. Just click Save Changes at the bottom after doing so.

提示:不确定{admin_email}是否是您的电子邮件地址? 转到WordPress信息中心中的“设置”»“常规” 。 查找管理电子邮件地址。 您可以在这里更改。 之后,只需单击底部的“保存更改”即可。

Checking or changing the WordPress Administration email address

If you want the submitted files to be sent to more than one person, you can also set up multiple notifications here.

如果要将提交的文件发送给多个人,则还可以在此处设置多个通知

You may also want to change the confirmation message that users sees after the form is submitted. You can do this under Settings » Confirmations.

您可能还希望更改提交表单后用户看到的确认消息。 您可以在设置»确认下执行此操作。

Simply type the message you want into the box. You can add formatting like bold and italic if you want to. This is how the default message looks:

只需在框中输入您想要的消息。 您可以根据需要添加粗体和斜体等格式。 这是默认消息的外观:

Changing the confirmation message that the user sees after submitting the form

Don’t forget to save your form once you’ve made changes. You can exit the form builder by clicking the X in the top right.

进行更改后,请不要忘记保存表单。 您可以通过单击右上角的X退出表单构建器。

将文件上传表单添加到您的网站 (Adding Your File Upload Form to Your Website)

Once you’ve created your form, you’ll need to add it to your website. You can add it on an existing post or page, or you can create a new page.

创建表单后,您需要将其添加到您的网站。 您可以将其添加到现有帖子或页面上 ,也可以创建一个新页面。

We’re going to add our form to a new page. To create a new page, go to Pages » Add New. Then, add a new block to your page by clicking the (+) icon.

我们将表单添加到新页面。 要创建新页面,请转到页面»添加新页面 。 然后,通过单击(+)图标将新的块添加到您的页面。

Creating a new page in WordPress and adding a new block to it

Next, you’ll need to select the WPForms block from the Widgets section. You can use the search bar to find it if you prefer.

接下来,您需要从“小部件”部分中选择WPForms块。 如果愿意,可以使用搜索栏找到它。

Adding the WPForms block to your page or post

After you’ve added the block to your page, select the form that you created from the WPForms dropdown.

在将块添加到页面后,从WPForms下拉列表中选择您创建的表单。

Select the correct form from the WPForms dropdown

Now, preview or publish your page and take a look at your form live on your site. Here’s how our form looks.

现在,预览或发布您的页面,并实时查看您网站上的表单。 这是我们表格的外观。

The finished file upload form live on the website

You can make changes to your form by going to WPForms » All Forms. Just click on the name of the form, or run your mouse over it and click the ‘Edit’ link, to edit it.

您可以转到WPForms»所有表单更改表单。 只需单击表单的名称,或将鼠标悬停在该表单上,然后单击“编辑”链接即可对其进行编辑。

Editing a form you've already created in WPFormsv

When you edit your form, it’s automatically updated on your website. You don’t need to add it to your page again.

当您编辑表单时,它会在您的网站上自动更新。 您无需再次将其添加到页面中。

Tip: It’s a good idea to test your form to make sure it’s working as expected. If you don’t get an email notification after creating a form entry, then take a look at our step by step guide on fixing the WordPress not sending email issue.

提示:最好测试一下表单以确保其正常工作。 如果您在创建表单条目后没有收到电子邮件通知,请查看我们的逐步指南,以解决WordPress不发送电子邮件的问题

查看或下载上传的文件 (Viewing or Downloading the Uploaded Files)

When someone sends a file through your file upload form, you can get it through your email inbox or through your WordPress dashboard.

当有人通过您的文件上传表单发送文件时,您可以通过电子邮件收件箱或WordPress仪表板获取文件。

With each form entry, you’ll get an email like this:

在每个表单条目中,您都会收到如下电子邮件:

The email you receive with the form entry details, including file download links

Just click the links to view or download the files themselves.

只需单击链接即可查看或下载文件本身。

You can also easily find the files through WordPress itself. Go to WPForms » Entries then click on the name of your form.

您也可以通过WordPress本身轻松找到文件。 转到WPForms»条目,然后单击您的表单名称。

Select your form to view the form entries in your WordPress dashboard

Next, you can see the uploaded files in the table of form entries. Alternatively, you can click the View link to see the full details of the form entry.

接下来,您可以在表单条目表中看到上载的文件。 或者,您可以单击查看链接以查看表单条目的完整详细信息。

The file links shown in the WPForms entry in the table

We hope this tutorial helped you learn how to create a file upload form in WordPress. You might also want to check out our guide on the best WordPress survey plugins and our guide on how to create an email newsletter.

我们希望本教程可以帮助您学习如何在WordPress中创建文件上传表单。 您可能还想查看有关最佳WordPress调查插件的指南以及有关如何创建电子邮件通讯的指南

If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Facebook.

如果您喜欢这篇文章,请订阅我们的YouTube频道 WordPress视频教程。 您也可以在TwitterFacebook上找到我们。

翻译自: https://www.wpbeginner.com/wp-tutorials/how-to-create-a-file-upload-form-in-wordpress/

wordpress表单调用

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值