Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.ArgumentException: Parameter is not valid.
Source Error:
Line 67:
Line 68: var mediaImage = Media.MakeNew(fileName, fileMediaType, user, folder.Id);
Line 69: mediaImage.getProperty("umbracoFile").Value = file; Line 70: }
Line 71:
Source File: C:\My VS Project\umbraco4-clean\Training.Level2-Clean\Training.Level2\usercontrols\CommentForm.ascx.cs Line: 69
Umbraco 4.8 - Parameter is not valid - error when tryin to upload media files programetically..
hi,
i am using umbraco 4.8 ...and trying to upload image files programetically to media section ... using user control ....
everything working fine if i am creating node and uploading images to node sub child ...as a upload file ...
but when i am trying to upload same images to media folder .... it gives me this error ....
if i chnage the order of the code ...means creating images to media folder then it gives me error when i creating node to content ,,,,
not sure what is wrong .....
here is trace error...
also i am using this code to create node and media files to media sections.....
any help would be appriciated ...
cheers,
jigs
Error:
Server Error in '/' Application.
Parameter is not valid.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.ArgumentException: Parameter is not valid.
Source Error:
Line 67: Line 68: var mediaImage = Media.MakeNew(fileName, fileMediaType, user, folder.Id); Line 69: mediaImage.getProperty("umbracoFile").Value = file; Line 70: } Line 71:
Source File: C:\My VS Project\umbraco4-clean\Training.Level2-Clean\Training.Level2\usercontrols\CommentForm.ascx.cs Line: 69
Stack Trace:
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.272
Code: i am using is ....
for (int i = 0; i < Request.Files.Count; i++)
{
HttpPostedFile file = Request.Files[i];
var fileType = DocumentType.GetByAlias("StatusUpdateFile");
var fileName = "File-" + DateTime.Now.Ticks.ToString();
var statusFile = Document.MakeNew(fileName, fileType, user, d.Id);
statusFile.getProperty("upload").Value = file;
statusFile.Publish(user);
umbraco.library.UpdateDocumentCache(statusFile.Id);
}
// adding images to media folder
var mt = MediaType.GetByAlias("Folder");
var folder = Media.MakeNew(name, mt, user, -1);
for (int i = 0; i < Request.Files.Count; i++)
{
HttpPostedFile file = Request.Files[i];
var fileMediaType = MediaType.GetByAlias("File");
var fileName = "File-" + DateTime.Now.Ticks.ToString();
var mediaImage = Media.MakeNew(fileName, fileMediaType, user, folder.Id);
mediaImage.getProperty("umbracoFile").Value = file;
}
is working on a reply...