真的难倒在这里为什么这不起作用......
我有一个输入和一个按钮,我用它来获取文件路径以便以后做一些工作。我遇到的问题是,如果我选择一个~3gb文件,我的提交操作就像预期的那样工作。如果我选择~4gb或~5gb文件,我的提交操作将不再有效。什么都没有回到服务器。我不上传。我只是使用选择的文件路径。知道发生了什么事吗?这是使用IE浏览器。
更新:这适用于Chrome,但由于我无法正确获取路径,因此我的功能失败。
文件选择代码:
public CmtMediaUiGenerator<TModel> video(
Expression<Func<TModel, MediaFileViewModel>> fileExpression,
Expression<Func<TModel, bool>> widescreenExpression,
Expression<Func<TModel, int?>> formatExpression,
Expression<Func<TModel, bool>> encryptedExpression = null,
bool stacked = false,
object htmlAttributes = null)
{
string id = Guid.NewGuid().ToString("n");
MvcHtmlString label = HtmlHelper.LabelFor(fileExpression, htmlAttributes: new { @class = "label" });
//MvcHtmlString id = HtmlHelper.IdFor(expression);
StringBuilder validationMessages = new StringBuilder();
validationMessages.Append(HtmlHelper.ValidationMessageFor(fileExpression).ToHtmlString());
validationMessages.Append(HtmlHelper.ValidationMessageFor(widescreenExpression).ToHtmlString());
validationMessages.Append(HtmlHelper.ValidationMessageFor(formatExpression).ToHtmlString());
StringBuilder html = new StringBuilder();
html.AppendFormat("<div class=\"video-container\" id=\"{0}\">", id);
html.Append("<div class=\"video-file-container\">");
string fileId = HtmlHelper.IdFor(fileExpression).ToHtmlString();
MediaFileViewModel fileValue = fileExpression.Compile().Invoke(Model);
html.AppendFormat("<input type=\"hidden\" id=\"{0}.FilePath\" name=\"{0}.FilePath\" value=\"{2}\" />"
+ "<input type=\"hidden\" id=\"{0}.MediaFileId\" name=\"{0}.MediaFileId\" value=\"{3}\" />"
+ "<button id=\"{0}-button\" class=\"button button-small\">Select File</button>"
+ "<span id=\"{0}-value\" class=\"display-value file-name-display\">{1}</span>",
fileId,
(fileValue == null ? null : Path.GetFileName(fileValue.FilePath)),
(fileValue == null ? null : fileValue.FilePath),
(fileValue == null ? 0 : fileValue.MediaFileId));
html.Append("</div>");
html.Append("<div>");
string widescreenId = HtmlHelper.IdFor(widescreenExpression).ToHtmlString();
bool widescreenValue = widescreenExpression.Compile().Invoke(Model);
html.AppendFormat("<div class=\"checkbox-value\">"
+ "<input type=\"checkbox\" id=\"{0}\" name=\"{0}\" value=\"true\" disabled {1} />"
+ "<label for=\"{0}\">Widescreen</label>"
+ "</div>",
widescreenId, (widescreenValue ? "checked" : ""));
string formatId = HtmlHelper.IdFor(formatExpression).ToHtmlString();
int? formatValue = formatExpression.Compile().Invoke(Model);
html.AppendFormat("<input type=\"hidden\" id=\"{0}\" name=\"{0}\" value=\"{1}\" />"
+ "<div class=\"label\">Format:</div><span id=\"{0}-value\" class=\"format-value\">{2}</span>",
formatId, formatValue,
(formatValue == null ? "n/a" : string.Format("MPEG {0}", formatValue)));
string encryptedId = (encryptedExpression == null ? null
: HtmlHelper.IdFor(encryptedExpression).ToHtmlString());
if (encryptedExpression != null)
{
bool encryptedValue = encryptedExpression.Compile().Invoke(Model);
html.AppendFormat("<div class=\"checkbox-value\">"
+ "<input type=\"checkbox\" id=\"{0}\" name=\"{0}\" value=\"true\" disabled {1} />"
+ "<label for=\"{0}\">Encrypted</label>"
+ "</div>",
encryptedId, (encryptedValue ? "checked" : ""));
validationMessages.Append(HtmlHelper.ValidationMessageFor(encryptedExpression).ToHtmlString());
}
html.Append("</div>");
html.AppendFormat("<script>$(function() {{ setUpVideoUpload('{0}', '{1}', '{2}', '{3}', {4}); }});</script>",
id,
fileId,
widescreenId,
formatId,
(encryptedId == null ? "null" : "'" + encryptedId + "'"));
html.Append("</div>");
GenerateEditItemSet(id, label.ToHtmlString(), html.ToString(), validationMessages.ToString(),
stacked: stacked,
valueCssClass: "file-value");
return (this);
//new string[] { "1", "2", "4" }
}
提交:
public CmtMediaUiGenerator<TModel> saveCancelButtons()
{
Output.Append("<hr />"
+ "<p>"
+ "<a href=\"/Media/\" class=\"button\">Cancel</a>"
+ "<input type=\"submit\" name=\"PostAction\" value=\"Save\" class=\"button button-primary\" />"
+ "<input type=\"submit\" name=\"PostAction\" value=\"Save & Close\" class=\"button button-primary\" />"
+ "</p>");
return (this);
}
提前致谢!