[ gogi100 @ 20.09.2017. 12:06 ] @
imam stranicu za upload dokumenata. kad kliknem na dugme submit dobijam gresku Citat: Server Error in '/' Application. -------------------------------------------------------------------------------- Koristite SPFileCollection.Add() da biste dodali neku stavku u biblioteku dokumenata. 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: Microsoft.SharePoint.SPException: Koristite SPFileCollection.Add() da biste dodali neku stavku u biblioteku dokumenata. Source Error: An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below. Stack Trace: [SPException: Koristite SPFileCollection.Add() da biste dodali neku stavku u biblioteku dokumenata.] Microsoft.SharePoint.SPListItem.PrepareItemForUpdate(SPWeb web, Boolean bMigration, Boolean& bAdd, Boolean& bPublish, Object& objAttachmentNames, Object& objAttachmentContents, Int32& parentFolderId) +546 Microsoft.SharePoint.SPListItem.UpdateInternal(Boolean bSystem, Boolean bPreserveItemVersion, Guid newGuidOnAdd, Boolean bMigration, Boolean bPublish, Boolean bNoVersion, Boolean bCheckOut, Boolean bCheckin, Boolean suppressAfterEvents, String filename, Boolean bPreserveItemUIVersion) +315 Microsoft.SharePoint.SPListItem.Update() +166 MultipleUploadWebpart.VisualWebPart1.VisualWebPart1.btnSubmit_Click(Object sender, EventArgs e) +1814 System.Web.UI.WebControls.Button.OnClick(EventArgs e) +115 System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +140 System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +29 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2981 kod za submit dugme je: Code: private void btnSubmit_Click(object sender, EventArgs e) { SPWeb site = SPContext.Current.Web; SPList list = site.Lists["MultipleUpload"]; SPListItem myNewItem ; dt = (DataTable)Page.Session["Files"]; int _dtcnt = dt.Rows.Count; string strDate=""; foreach (DataRow dr in dt.Rows) { strDate = System.DateTime.Now.Date.TimeOfDay.ToString(); myNewItem = list.Items.Add(); fileName = dr["Filename"].ToString(); string strFilepath = dr["FilePath"].ToString(); StreamReader sr = new StreamReader(strFilepath); Stream fStream=sr.BaseStream ; contents = new byte[fStream.Length]; fStream.Read(contents, 0, (int)fStream.Length); fStream.Close(); myNewItem["Ime"] = dr["Filename"].ToString(); myNewItem["Tip dokumenta"] = dr["FileSize"].ToString(); myNewItem["Datum prebacivanja"] = strDate; myNewItem.Attachments.Add(fileName, contents); myNewItem.Update(); System.IO.File.Delete(strFilepath); } lblMessage.Text = "Uspešno poslato"; } |