AI OnAI Off
You can see if there is any request to server which return 500 error, looking to the message on that. It will be a hint to determine your proplem.
I found the problem with this.
When uploading am image the mediadata we have set up for images has a required property, as this isn't set it fails the validation.
To get round I used a custom DataSubmissionService which turns off the validation check for files by overriding the StorePostedFile and in the FileContentLink set SaveAction.SkipValidation
[ServiceConfiguration(typeof(DataSubmissionService), Lifecycle = ServiceInstanceScope.Singleton)]
public class CustomDataSubmissionService : DataSubmissionService
{
protected override FileSaveItem StorePostedFile(long postId, HttpPostedFileBase postedFile,
ContentReference folderLink)
{
var fileName = postedFile.FileName;
var fileSaveItem = new FileSaveItem {FileName = fileName, FileSize = (long) postedFile.ContentLength};
var str1 = Path.GetFileNameWithoutExtension(fileName);
if (!string.IsNullOrWhiteSpace(str1) && str1.Length > 50)
str1 = str1.Substring(0, 50);
var str2 = new Regex(
$"[^{(object) ServiceLocator.Current.GetInstance<UrlSegmentOptions>().ValidCharacters}]{{1}}").Replace(Path.GetExtension(fileName), "-");
try
{
var contentType = this._contentTypeRepository.Service.Load(this._contentMediaResolver.Service.GetFirstMatching(str2));
var contentMedia = this._contentRepository.Service.GetDefault<IContentMedia>(folderLink, contentType.ID);
var blob = this._blobFactory.Service.CreateBlob(contentMedia.BinaryDataContainer, Path.GetExtension(str2));
DataSubmissionService._logger.Debug("Blob is created at \"{0}\".", (object)blob.ID);
blob.Write(postedFile.InputStream);
contentMedia.Name = $"{(object) str1}_{(object) postId}{(object) str2}";
contentMedia.BinaryData = blob;
fileSaveItem.FileContentLink = this._contentRepository.Service.Save((IContent)contentMedia, SaveAction.SkipValidation, AccessLevel.NoAccess);
DataSubmissionService._logger.Debug("Content for file \"{0}\" is created.", (object)fileName);
fileSaveItem.Success = true;
}
catch (Exception ex)
{
DataSubmissionService._logger.Error("Could not store the posted file.", ex);
return (FileSaveItem)null;
}
return fileSaveItem;
}
}
Whenever I try to upload a file on a form I get the following js error:
If I don't add a file then the form submits fine. This is on my local dev environment.
Using EpiServer CMS V11.9 and EPiserver Forms V4.14.1