问题描述
这是用ejs编写的形式。
<form class="product-form" action="/admin/<% if (editing) { %>edit-product<% } else { %>add-product<% } %>" method="POST" enctype="multipart/form-data">
<div class="form-control">
<label for="title">Title</label>
<input
class="<%= validationErrors.find(e => e.param === 'title') ? 'invalid' : '' %>"
type="text"
name="title"
id="title"
value="<% if (editing || hasError) { %><%= product.title %><% } %>">
</div>
<div class="form-control">
<label for="image">Image</label>
<input
type="file"
name="image"
id="image" >
</div>
<div class="form-control">
<label for="price">Price</label>
<!-- express-validator returns array of errors -->
<input
class="<%= validationErrors.find(e => e.param === 'price') ? 'invalid' : '' %>"
type="number"
name="price"
id="price"
step="0.01"
value="<% if (editing || hasError) { %><%= product.price %><% } %>">
</div>
<div class="form-control">
<label for="description">Description</label>
<textarea
class="<%= validationErrors.find(e => e.param === 'description') ? 'invalid' : '' %>"
name="description"
id="description"
rows="5"><% if (editing || hasError) { %><%= product.description %><% } %></textarea>
</div>
<% if (editing) { %>
<input type="hidden" value="<%= product._id %>" name="productId">
<% } %>
<input type="hidden" name="_csrf" value="<%= csrftoken %>">
<button class="btn" type="submit"><% if (editing) { %>Update Product<% } else { %>Add Product<% } %></button>
</form>
由于我正在上传图片,enctype="multipart/form-data"
。当我点击按钮时,没有任何反应。没有发布请求,我检查了网络请求,什么都没有
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)