Pure ASP.NET Upload 2 Support Product Page

This topic was archived

Insert ignores filename C#

Reported 14 Jul 2006 15:00:59
1
has this problem
14 Jul 2006 15:00:59 Johan Van Dyk posted:
Hi

I have a page where I use the ASP.NET upload ext. Everything works as it should (Record gets added to the database and the file is uploaded) but the filename is not recorded in the database. All other fields are populated except the filename.

My code is as follows: Any help appreciated....rather urgent!!
___________________________________________________________
<%@ Page Language="C#" %>
<%@ Register TagPrefix="webxelauthentication" Namespace="WebXelAuthentication" Assembly="WebXelAuthentication" %>
<%@ Register TagPrefix="MM" Namespace="DreamweaverCtrls" Assembly="DreamweaverCtrls,version=1.0.0.0,publicKeyToken=836f606ede05d46a,culture=neutral" %>
<%@ Register TagPrefix="DMXzone" NameSpace="PureUpload" Assembly="PureUpload" %>
&lt;DMXzone<img src=../images/dmxzone/forum/icon_smile_tongue.gif border=0 align=middle>ureFileUpload runat="server" id="pfu" ThePath="../../GenResources" Redirect="" StoreType="file" TimeOut="600" SizeLimit="" Extensions="doc,xls,ppt,pps,pdf,zip" NameConflict="uniq" MaxHeight="" MinHeight="" RequireUpload="true" MinWidth="" MaxWidth="" SaveWidth="" SaveHeight="" FormName="form1" ProgressBar="" ProgressWidth="300" ProgressHeight="100" TheVersion="2.0.2" /&gt;&lt;MM<img src=../images/dmxzone/forum/icon_smile_blush.gif border=0 align=middle>nsert
runat="server"
CommandText='&lt;%# "INSERT INTO dbo.tblResources (R_Title, R_Resource, R_MemberID, R_Private, R_ClientID) VALUES (?, ?, ?, ?, ?)" %&gt;'
ConnectionString='&lt;%# System.Configuration.ConfigurationSettings.AppSettings["MM_CONNECTION_STRING_conn"] %&gt;'
DatabaseType='&lt;%# System.Configuration.ConfigurationSettings.AppSettings["MM_CONNECTION_DATABASETYPE_conn"] %&gt;'
Expression='&lt;%# Request.Form["MM_insert"] == "form1" %&gt;'
CreateDataSet="false"
SuccessURL='&lt;%# "ViewModifyResource.aspx" %&gt;'
&gt;
&lt;Parameters&gt;
&lt;Parameter Name="@R_Title" Value='&lt;%# ((Request.Form["R_Title"] != null) && (Request.Form["R_Title"].Length &gt; 0)) ? Request.Form["R_Title"] : "" %&gt;' Type="VarChar" /&gt;
&lt;Parameter Name="@R_Resource" Value='&lt;%# ((Request.Form["R_Resource"] != null) && (Request.Form["R_Resource"].Length &gt; 0)) ? Request.Form["R_Resource"] : "" %&gt;' Type="VarChar" /&gt;
&lt;Parameter Name="@R_MemberID" Value='&lt;%# ((Request.Form["R_MemberID"] != null) && (Request.Form["R_MemberID"].Length &gt; 0)) ? Request.Form["R_MemberID"] : "" %&gt;' Type="Integer" /&gt;
&lt;Parameter Name="@R_Private" Value='&lt;%# ((Request.Form["R_Private"] != null) && (Request.Form["R_Private"].Length &gt; 0)) ? Request.Form["R_Private"] : "" %&gt;' Type="WChar" /&gt;
&lt;Parameter Name="@R_ClientID" Value='&lt;%# ((Request.Form["R_ClientID"] != null) && (Request.Form["R_ClientID"].Length &gt; 0)) ? Request.Form["R_ClientID"] : "" %&gt;' Type="Integer" /&gt;
&lt;/Parameters&gt;
&lt;/MM<img src=../images/dmxzone/forum/icon_smile_blush.gif border=0 align=middle>nsert&gt;
&lt;MM<img src=../images/dmxzone/forum/icon_smile_tongue.gif border=0 align=middle>ageBind runat="server" PostBackBind="true" /&gt;
&lt;HTML&gt;
&lt;HEAD&gt;
&lt;%
Response.Expires=-1000;
Response.CacheControl="no-cache";
%&gt;
&lt;TITLE&gt;Peer Educator&lt;/TITLE&gt;
&lt;link href="../../Assets/Css/&lt;%= Session["CSS"] %&gt;" rel="stylesheet" type="text/css"&gt;
&lt;script src="../../Assets/Scripts/Rightclick.js"&gt;&lt;/script&gt;
&lt;script runat="server"&gt;
protected void Page_Load(Object Src, EventArgs E)
{
if (!IsPostBack)
{
R_MemberID.Value = CheckLoginStatus1.CurrentUser["MemberID"];
R_ClientID.Value = Session["ClientID"].ToString();
}
}
&lt;/script&gt;
&lt;script language='javascript' src='../../ScriptLibrary/incPureUpload.js'&gt;&lt;/script&gt;
&lt;/HEAD&gt;
&lt;BODY&gt;
&lt;img name='awmMenuPathImg-Admin_sub' id='awmMenuPathImg-Admin_sub' src='../../Assets/Scripts/awmmenupath.gif' alt=''&gt;
&lt;script type='text/javascript'&gt;var MenuLinkedBy='AllWebMenus [2]', awmBN='DW'; awmAltUrl='';&lt;/script&gt;
&lt;script src='../../Assets/Scripts/Admin_sub.js' language='JavaScript1.2' type='text/javascript'&gt;&lt;/script&gt;
&lt;script type='text/javascript'&gt;awmBuildMenu();&lt;/script&gt;
&lt;WebXelAuthentication:CheckLoginStatus UserNotLoggedInURL="../../Errors/SessionExpired.aspx" AccessDeniedURL="../../Errors/SessionExpired.aspx" AccessLevel="1" CompareType="Equals" ID="CheckLoginStatus1" RestrictByAccessLevel="true" Runat="server"&gt;&lt;/WebXelAuthentication:CheckLoginStatus&gt;
&lt;h3&gt;Add Resources&lt;/h3&gt;
&lt;P&gt;&lt;SPAN class="note"&gt;Please Note:&lt;/SPAN&gt;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;If you add a resource which already exist, it will be renamed (filename will be appended with a _X where X is a numeric value) &lt;/LI&gt;
&lt;LI&gt;Only MS Office documents (&lt;STRONG&gt;.doc&lt;/STRONG&gt;, &lt;STRONG&gt;.ppt&lt;/STRONG&gt;, &lt;STRONG&gt;.pps&lt;/STRONG&gt;, &lt;STRONG&gt;.xls&lt;/STRONG&gt<img src=../images/dmxzone/forum/icon_smile_wink.gif border=0 align=middle>, Portable Document Format (&lt;STRONG&gt;.pdf&lt;/STRONG&gt<img src=../images/dmxzone/forum/icon_smile_wink.gif border=0 align=middle>, and WinZip (&lt;STRONG&gt;.zip&lt;/STRONG&gt<img src=../images/dmxzone/forum/icon_smile_wink.gif border=0 align=middle> files will be uploaded. Selecting any other document types will cancell the submission od this resource.&lt;/LI&gt;
&lt;/UL&gt;
&lt;form method='post' enctype="multipart/form-data" name='form1' id="form1" runat='server' onSubmit="checkFileUpload(this,'doc,xls,ppt,pps,pdf,zip',true,'','','','','','','');return document.MM_returnValue"&gt;
&lt;table border="0" cellspacing="1" cellpadding="0"&gt;
&lt;tr&gt;
&lt;th&gt;Title&lt;/th&gt;
&lt;td colspan="2"&gt;&lt;asp:TextBox ID="R_Title" Columns="80" MaxLength="200" runat="server" /&gt;
&lt;asp:RequiredFieldValidator ControlToValidate="R_Title" CssClass="errormessage" Display="Dynamic" ErrorMessage="&lt;br&gt;Please supply a &lt;b&gt;Title&lt;/b&gt;!" ID="RequiredFieldValidator1" runat="server"&gt;&lt;/asp:RequiredFieldValidator&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;th&gt;Resource
&lt;input name="R_MemberID" type="hidden" id="R_MemberID" runat="server"&gt;
&lt;input name="R_ClientID" type="hidden" id="R_ClientID" runat="server"&gt;
&lt;input id="R_Private" name="R_Private" runat="server" type="hidden" value="No"&gt;&lt;/th&gt;
&lt;td colspan="2"&gt;&lt;input name="R_Resource" type="file" id="R_Resource" onChange="checkOneFileUpload(this,'doc,xls,ppt,pps,pdf,zip',true,'','','','','','','')" size="80" runat="server"&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&nbsp;&lt;/td&gt;
&lt;td colspan="2"&gt;&lt;asp:Button ID="Submit" runat="server" Text="Add Resource" /&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;input type="hidden" name="MM_insert" value="form1"&gt;
&lt;/form&gt;
&lt;/BODY&gt;
&lt;/HTML&gt;
___________________________________________________________

Johan Van Dyk

Replies

Replied 14 Jul 2006 16:51:06
14 Jul 2006 16:51:06 Robbie Laliberte replied:
Johan,

try this as the value of your parameter R_Resource (that is the file input field, yes); no guarantees, because I really don't do C#.


((R_Resource.Value != null) && (R_Resource.Value.Length &gt; 0)) ? R_Resource.Value.Substring(R_Resource.Value.LastIndexof("\" + 1) : ""

Original tales of Dark Fantasy and Horror. www.theHarrow.com
Replied 27 Jul 2006 14:36:19
27 Jul 2006 14:36:19 Robbie Laliberte replied:
Did this work for you, Johan?

Original tales of Dark Fantasy and Horror. www.theHarrow.com

Reply to this topic