Note that there are some explanatory texts on larger screens.

plurals
  1. POCannot upload Image to a SharePoint List
    text
    copied!<p>I'm working with a Visual WebPart and I want to upload a image from my FileUpload control to a SharePoint list. This is the code I'm using but I can't get it to work, (Title, prodnum, color, etc is working, but not image). I've also installed <a href="http://www.sparqube.com/SharePoint-Picture-Column/" rel="nofollow noreferrer">SparQube</a>.</p> <p>This is my ListView: <a href="http://i47.tinypic.com/x5z2v7.jpg" rel="nofollow noreferrer">Image http://i47.tinypic.com/x5z2v7.jpg</a>.</p> <pre><code>protected void Button_Save_Click(object sender, EventArgs e) { SPSite currentSite = SPContext.Current.Site; SPList myList = currentSite.RootWeb.Lists.TryGetList("SharePointDatabase"); try { if (myList != null &amp;&amp; FileUpload_Pic.PostedFile != null &amp;&amp; FileUpload_Pic.HasFile) { SPListItem listItem = myList.Items.Add(); listItem["Title"] = TextBox_Name.Text; listItem["ProductNumber"] = TextBox_ProdNum.Text; listItem["Color"] = TextBox_Color.Text; listItem["ListPrice"] = TextBox_ListPrice.Text; listItem["MoreInformation"] = TextBox_MoreInfo.Text; string fileName = Path.GetFileName(FileUpload_Pic.PostedFile.FileName); listItem["Image"] = fileName; listItem.Update(); TextBox_Search.Text = string.Empty; TextBox_Name.Text = string.Empty; TextBox_MoreInfo.Text = string.Empty; TextBox_ProdNum.Text = string.Empty; TextBox_Color.Text = string.Empty; TextBox_ListPrice.Text = string.Empty; Label_Exception.Text = "Saved to Database list."; Dispose(); } } catch (Exception x) { Label_Exception.Text = x.Message; } } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload