"The maximum amount of data that you can upload is NaN undefined" 使用 Sitecore 中的 "Upload Media" 按钮上传图片时出现错误
"The maximum amount of data that you can upload is NaN undefined" error is coming on uploading an image using "Upload Media" button in Sitecore
我正在尝试使用以下过程上传媒体:
- 单击站点核心项目中图像字段的 "Browse"。
- 单击 "Upload Media" 按钮。
- 点击 "Browse for Media files" 并上传一张新图片。
按照上述步骤,我收到了这个错误信息:
The maximum amount of data that you can upload is NaN undefined.
因此图片没有上传。但是,我可以在媒体库中上传图片,然后将其链接到该项目,但是当我尝试直接从内容项目上传媒体时,出现错误。
如何解决这个问题?
PFB 表单标记语句
<form data-sc-id="Uploader" data-sc-databasename="master" data-sc-maxrequestlength="-1024" data-sc-executiontimeout="600" data-sc-destinationurl="/sitecore/media
library/Images/Social/Connector/download" data-sc-filesizeexceededtext="The maximum amount of data that you can upload is" data-sc-timeoutext="The media files could
not be uploaded. Please try again." class="sc-uploader row sc_Uploader_42 data-sc-registered" data-sc-require="/-/speak/v1/business/uploader.js" method="POST"
enctype="multipart/form-data">
<img class="sc-uploader-preview hide">
<div class="sc-uploader-content">
<span class="drag">
Drag and drop files here
<br>
or
<br>
</span>
<a href="#" class="btn btn-default sc-button sc_Button_14 data-sc-registered">
Browse for media files
<input class="sc-uploader-fileupload" type="file" name="files[]" multiple="" data-url="/api/sitecore/Media/Upload?
database=master&destinationUrl=/sitecore/media library/Images/Social/Connector/download">
</a>
<div class="sc-uploader-general-info">
<div class="sc-uploader-general-info-progressbar progress progress-success progress-striped active" role="progressbar" aria-valuemin="0" aria-valuemax="100"
style="display: none;">
<div class="bar data-sc-registered" data-bind="style: { width: globalPercentage() + '%' }" style="width: 0%;"></div>
</div>
<div class="sc-uploader-general-info-data" style="display: block;">
<div class="sc-uploader-general-info-data-col col1">
<div class="sc-uploader-general-info-data-uploadingData" style="display: none;"><span data-bind="text: uploadedSize" class="data-sc-
registered">0</span> of </div><span data-bind=" text: totalSize" class="data-sc-registered">11.2 Kb</span>
</div>
<div class="sc-uploader-general-info-data-col col2">|</div>
<div class="sc-uploader-general-info-data-col col3">
<div class="sc-uploader-general-info-data-uploadingData" style="display: none;">
<span data-bind=" text: uploadedFiles" class="data-sc-registered">0</span> of
</div>
<span data-bind=" text: totalFiles" class="data-sc-registered">1</span> <span data-bind=" visible: totalFiles() > 1" class="data-sc-registered"
style="display: none;">Files</span>
<span data-bind=" visible: totalFiles() === 1" class="data-sc-registered">File</span>
</div>
</div>
</div>
</div>
</form>
您需要检查是否已从 web.config
设置了 maxRequestLength,或者您可以从 IIS 更新它。
Web.config 方式
导航到路径:system.web/httpRuntime
并检查您是否有 httpRuntime
的条目。如果没有,您需要指定一个如下:
<httpRuntime maxRequestLength="512000" executionTimeout="3600" enableKernelOutputCache="false" relaxedUrlToFileSystemMapping="true" requestValidationMode="4.0" enableVersionHeader="false" />
注意长度以千字节为单位
IIS方式
- 打开 IIS
- 单击要接受更大文件大小的站点
- 在主 window 中双击“请求过滤”
- 在顶部选项卡上右键单击以查看选项和select“编辑功能设置”
- 现在更改“最大允许内容长度(字节)”字段中的数字
如果存在,您可能需要增加长度。
更新
如您所见,属性 data-sc-maxrequestlength="-1024"
具有负值,这就是出现上述错误的原因。所以,问题出在最大请求长度上。
我正在尝试使用以下过程上传媒体:
- 单击站点核心项目中图像字段的 "Browse"。
- 单击 "Upload Media" 按钮。
- 点击 "Browse for Media files" 并上传一张新图片。
按照上述步骤,我收到了这个错误信息:
The maximum amount of data that you can upload is NaN undefined.
因此图片没有上传。但是,我可以在媒体库中上传图片,然后将其链接到该项目,但是当我尝试直接从内容项目上传媒体时,出现错误。
如何解决这个问题?
PFB 表单标记语句
<form data-sc-id="Uploader" data-sc-databasename="master" data-sc-maxrequestlength="-1024" data-sc-executiontimeout="600" data-sc-destinationurl="/sitecore/media
library/Images/Social/Connector/download" data-sc-filesizeexceededtext="The maximum amount of data that you can upload is" data-sc-timeoutext="The media files could
not be uploaded. Please try again." class="sc-uploader row sc_Uploader_42 data-sc-registered" data-sc-require="/-/speak/v1/business/uploader.js" method="POST"
enctype="multipart/form-data">
<img class="sc-uploader-preview hide">
<div class="sc-uploader-content">
<span class="drag">
Drag and drop files here
<br>
or
<br>
</span>
<a href="#" class="btn btn-default sc-button sc_Button_14 data-sc-registered">
Browse for media files
<input class="sc-uploader-fileupload" type="file" name="files[]" multiple="" data-url="/api/sitecore/Media/Upload?
database=master&destinationUrl=/sitecore/media library/Images/Social/Connector/download">
</a>
<div class="sc-uploader-general-info">
<div class="sc-uploader-general-info-progressbar progress progress-success progress-striped active" role="progressbar" aria-valuemin="0" aria-valuemax="100"
style="display: none;">
<div class="bar data-sc-registered" data-bind="style: { width: globalPercentage() + '%' }" style="width: 0%;"></div>
</div>
<div class="sc-uploader-general-info-data" style="display: block;">
<div class="sc-uploader-general-info-data-col col1">
<div class="sc-uploader-general-info-data-uploadingData" style="display: none;"><span data-bind="text: uploadedSize" class="data-sc-
registered">0</span> of </div><span data-bind=" text: totalSize" class="data-sc-registered">11.2 Kb</span>
</div>
<div class="sc-uploader-general-info-data-col col2">|</div>
<div class="sc-uploader-general-info-data-col col3">
<div class="sc-uploader-general-info-data-uploadingData" style="display: none;">
<span data-bind=" text: uploadedFiles" class="data-sc-registered">0</span> of
</div>
<span data-bind=" text: totalFiles" class="data-sc-registered">1</span> <span data-bind=" visible: totalFiles() > 1" class="data-sc-registered"
style="display: none;">Files</span>
<span data-bind=" visible: totalFiles() === 1" class="data-sc-registered">File</span>
</div>
</div>
</div>
</div>
</form>
您需要检查是否已从 web.config
设置了 maxRequestLength,或者您可以从 IIS 更新它。
Web.config 方式
导航到路径:system.web/httpRuntime
并检查您是否有 httpRuntime
的条目。如果没有,您需要指定一个如下:
<httpRuntime maxRequestLength="512000" executionTimeout="3600" enableKernelOutputCache="false" relaxedUrlToFileSystemMapping="true" requestValidationMode="4.0" enableVersionHeader="false" />
注意长度以千字节为单位
IIS方式
- 打开 IIS
- 单击要接受更大文件大小的站点
- 在主 window 中双击“请求过滤”
- 在顶部选项卡上右键单击以查看选项和select“编辑功能设置”
- 现在更改“最大允许内容长度(字节)”字段中的数字
如果存在,您可能需要增加长度。
更新
如您所见,属性 data-sc-maxrequestlength="-1024"
具有负值,这就是出现上述错误的原因。所以,问题出在最大请求长度上。