Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
im trying to retreive the admin user with: User user = new User(0);
from some code in nforum i installed. but it throws:No node exists with id '0'
i wonder why??
Hi Amigo
Could you perhaps post the whole code snippet? Maybe you're missing a reference or something?Where does i throw the error?
/Jan
Hi Jan,
Its when i edit a nforum user and i try to upload an profile image, the line:User user = new User(0); throw the error...
.......Member m = Member.GetCurrentMember();m.getProperty("profileImage").Value = GenerateImage(FileUploadControl).Id;.......
private Media GenerateImage(FileUpload ProfileImageUpload) { User user = new User(0); Media media = Media.MakeNew(CurrentMember.MemberLoginName, MediaType.GetByAlias("image"), user, MediaParentNodeId); string mediaPath = Server.MapPath("/media"); string filePath = mediaPath + "/" + media.Id + "/" + ProfileImageUpload.PostedFile.FileName; Directory.CreateDirectory(mediaPath + "/" + media.Id); ProfileImageUpload.PostedFile.SaveAs(filePath); System.Drawing.Image.GetThumbnailImageAbort myCallback = new System.Drawing.Image.GetThumbnailImageAbort(ThumbnailCallback); Bitmap image = new Bitmap(ProfileImageUpload.PostedFile.InputStream); Bitmap thumb = (Bitmap)image.GetThumbnailImage(150, 150, myCallback, IntPtr.Zero); thumb.Save(filePath.Replace(".jpg", "_thumb.jpg")); media.getProperty("umbracoFile").Value = "/media/" + "/" + media.Id + "/" + ProfileImageUpload.PostedFile.FileName; return media; }
and i also have the : using umbraco.BusinessLogic; ...
hmmm, i just found out that it works when i haved a normal usercontrol in the umbraco site.But its not working when i try from the nforum project where the dll is copied to my site...
Hi Jan, it was my "MediaParentNodeId" that caused the problem..Problem solved.
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
retreiving the admin user generates an error.
im trying to retreive the admin user with: User user = new User(0);
from some code in nforum i installed. but it throws:
No node exists with id '0'
i wonder why??
Hi Amigo
Could you perhaps post the whole code snippet? Maybe you're missing a reference or something?
Where does i throw the error?
/Jan
Hi Jan,
Its when i edit a nforum user and i try to upload an profile image, the line:
User user = new User(0); throw the error...
.......
Member m = Member.GetCurrentMember();
m.getProperty("profileImage").Value = GenerateImage(FileUploadControl).Id;
.......
private Media GenerateImage(FileUpload ProfileImageUpload)
{
User user = new User(0);
Media media = Media.MakeNew(CurrentMember.MemberLoginName, MediaType.GetByAlias("image"), user, MediaParentNodeId);
string mediaPath = Server.MapPath("/media");
string filePath = mediaPath + "/" + media.Id + "/" + ProfileImageUpload.PostedFile.FileName;
Directory.CreateDirectory(mediaPath + "/" + media.Id);
ProfileImageUpload.PostedFile.SaveAs(filePath);
System.Drawing.Image.GetThumbnailImageAbort myCallback = new System.Drawing.Image.GetThumbnailImageAbort(ThumbnailCallback);
Bitmap image = new Bitmap(ProfileImageUpload.PostedFile.InputStream);
Bitmap thumb = (Bitmap)image.GetThumbnailImage(150, 150, myCallback, IntPtr.Zero);
thumb.Save(filePath.Replace(".jpg", "_thumb.jpg"));
media.getProperty("umbracoFile").Value = "/media/" + "/" + media.Id + "/" + ProfileImageUpload.PostedFile.FileName;
return media;
}
and i also have the : using umbraco.BusinessLogic; ...
hmmm, i just found out that it works when i haved a normal usercontrol in the umbraco site.
But its not working when i try from the nforum project where the dll is copied to my site...
Hi Jan, it was my "MediaParentNodeId" that caused the problem..
Problem solved.
is working on a reply...