Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Ed 1 post 21 karma points
    Dec 17, 2010 @ 17:26
    Ed
    0

    Very Newbie Question, file upload

    I am writing a custom usercontrol for Umbraco that will let a user edit their Bio Page. The bio pages are just documents with a 'bio' doctype. The bio doctype has name, address, etc and I've gotten my control to save those values to umbraco using the simple syntax:

                Document currentPage = new Document(Node.GetCurrent().Id);

                currentPage.getProperty("jobTitle").Value = JobTitleTextBox.Text;

    however, now I need to upload an image. So in the bio doctype, I created a 'bioImage' property ... is there an easy way to fill the file upload with the user's file from a Fileupload? is there an umbraco tag that gives you the same file upload as in the Admin portion of umbraco? I have been reading forums for days trying to find it.  here's what i have so far, which uploads the file to the server, and changes the media link, but it doesn't have the preview image in the Admin side, nor does it generate a thumbnail or anything. Am I doing this right?

     if (BioImageFileUpload.HasFile)

                {              

                    var fileName = Server.MapPath("~/media/" + currentPage.getProperty("bioImage").Id.ToString() + "/" + BioImageFileUpload.FileName);

                    Trace.Write(fileName);

                    BioImage.ImageUrl = "media/" + currentPage.getProperty("bioImage").Id.ToString() + "/" + BioImageFileUpload.FileName;

     

                    if(!Directory.Exists(Server.MapPath("~/media/"+currentPage.getProperty("bioImage").Id.ToString())))

                    {

                        Directory.CreateDirectory(Server.MapPath("~/media/" + currentPage.getProperty("bioImage").Id.ToString()));

                    }

     

                    BioImageFileUpload.SaveAs(fileName);

                    currentPage.getProperty("bioImage").Value = BioImage.ImageUrl;                 

                }

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies