Hello,
I'm using Umbraco 7.6.1 and Umbraco Forms 6.0.1. I'm trying to use a recaptcha on a page with a file upload.
I'm encountering 2 issues.
When server side validation fails and the client is returned to the form. I am encountering this issue: http://issues.umbraco.org/issue/CON-1221
Instead of a Dictionary<string, string>, Model.Values is returning an IEnumerable<string> of the file location of the temp file upload. To handle this I modified the FieldType.FileUpload.cshtml file to look like this:
@using Umbraco.Web
@using Umbraco.Forms.Mvc
@model Umbraco.Forms.Mvc.Models.FieldViewModel
<input type="file" class="@Html.GetFormFieldClass(Model.FieldTypeName)" name="@Model.Name" id="@Model.Id" multiple
@if(Model.Mandatory){<text> data-val="true" data-val-required="@Model.RequiredErrorMessage"</text>} />
@if (Model.Values != null && Model.Values.Any())
{
<p>
<strong>Current File/s:</strong><br/>
@*@foreach (Dictionary<string, string> dictionaryObject in Model.Values)
{
//The model.values contains a list of dictionary objects with a single item
//With the key being the full path to the file
//And the value being the filename
if (dictionaryObject.Count > 0)
{
var fileInfo = dictionaryObject.First();
Which renders fine. However, I didn't realize until after that the value in the Model.Values is actually issue #2... they are temp files in the app_data/temp folders and therefore can't be linked.
I'm not sure what else I can do at this point, any help would be appreciated.
@using Umbraco.Web
@using Umbraco.Forms.Mvc
@model Umbraco.Forms.Mvc.Models.FieldViewModel
<input type="file" class="@Html.GetFormFieldClass(Model.FieldTypeName)" name="@Model.Name" id="@Model.Id" multiple
@if(Model.Mandatory){<text> data-val="true" data-val-required="@Model.RequiredErrorMessage"</text>} />
@if (Model.Values != null && Model.Values.Any())
{
<p>
<strong>Current File/s:</strong><br/>
@foreach (object obj in Model.Values)
{
//if captcha validation fails, this will not be a dictionary of string,string
var dictionaryObject = obj as Dictionary<string, string>;
if (dictionaryObject == null)
{
continue;
}
@*
The model.values contains a list of dictionary objects with a single item
With the key being the full path to the file
And the value being the filename
*@
if (dictionaryObject.Count > 0)
{
var fileInfo = dictionaryObject.First();
<a href="@fileInfo.Key" target="_blank">@fileInfo.Value</a><br/>
<input type="hidden" name="@(Model.Name)_file_@(fileInfo.Value)" value="@fileInfo.Key" />
}
}
</p>
}
Umbraco forms 6 and file upload
Hello, I'm using Umbraco 7.6.1 and Umbraco Forms 6.0.1. I'm trying to use a recaptcha on a page with a file upload.
I'm encountering 2 issues.
When server side validation fails and the client is returned to the form. I am encountering this issue: http://issues.umbraco.org/issue/CON-1221 Instead of a
Dictionary<string, string>
, Model.Values is returning anIEnumerable<string>
of the file location of the temp file upload. To handle this I modified theFieldType.FileUpload.cshtml
file to look like this:Which renders fine. However, I didn't realize until after that the value in the Model.Values is actually issue #2... they are temp files in the
app_data/temp
folders and therefore can't be linked.I'm not sure what else I can do at this point, any help would be appreciated.
Here's how I fixed this:
is working on a reply...