try creating a custom page similar to this (i started working on it a while ago and never really implemented it):
<p> <%@ Page Language="C#" AutoEventWireup="true" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<asp:Panel ID="pnlUpload" runat="server">
<div style="height: 80px;">
<asp:Label ID="lblWelcomeMessage" runat="server" Text="Add an Attachment"
Font-Size="11px" Font-Names="'Lucida Grande',Verdana,Arial,Sans-Serif" ForeColor="#555555"></asp:Label>
<br /><br />
<asp:FileUpload ID="FileUpload1" runat="server" />
</div>
<div style="height: 30px;">
<asp:Button Text="Add" ID="btnUpload" runat="server" OnClick="btnUpload_Click" />
</div>
</asp:Panel>
<asp:Panel ID="pnlAfterUpload" runat="server" Visible="false">
<asp:Label ID="lblMessage" Text="Your File Has Been Successfully Saved" ForeColor="Red"
runat="server"></asp:Label>
</asp:Panel>
</form>
</body>
</html>
<script runat="server" type="text/C#">
protected override void OnLoad( EventArgs e )
{
}
protected void btnUpload_Click(object sender, EventArgs e)
{
string quoteid = Request.QueryString["q"];
try
{
//Get the root folder from web config.
string savePath = @"\\SERVER\ATTACHMENTS\" + quoteid + @"\";
string tempfileName = "";
if (!System.IO.Directory.Exists(savePath))
{
System.IO.DirectoryInfo di = System.IO.Directory.CreateDirectory(savePath);
}
if (FileUpload1.HasFile)
{
// Get the name of the file to upload.
String fileName = FileUpload1.FileName;
// Create the path and file name to check for duplicates.
string pathToCheck = savePath + fileName;
// Append the name of the file to upload to the path.
savePath += fileName;
// Check to see if a file already exists with the
// same name as the file to upload.
if (System.IO.File.Exists(pathToCheck))
{
int counter = 2;
while (System.IO.File.Exists(pathToCheck))
{
// if a file with this name already exists,
// prefix the filename with a number.
tempfileName = counter.ToString() + fileName;
pathToCheck = savePath + tempfileName;
counter ++;
}
fileName = tempfileName;
// Notify the user that the file name was changed.
lblMessage.Text = "A file with the same name already exists." + "<br />Your file was saved as " + fileName;
}
else
{
// Notify the user that the file was saved successfully.
lblMessage.Text = "Your file was uploaded successfully.";
}
// Call the SaveAs method to save the
// uploaded file to the specified path.
FileUpload1.SaveAs(savePath);
//Hide the upload panel
pnlUpload.Visible = false;
//View message to notify the user that the his file has been uploaded.
pnlAfterUpload.Visible = true;
string sql;
string oppquoteid = Request.QueryString["q"];
string connStr = "Provider=SQLOLEDB;integrated security=SSPI;data source=localhost;" + "persist security info=False;initial catalog=saleslogix;";
using (System.Data.OleDb.OleDbConnection conn = new System.Data.OleDb.OleDbConnection(connStr))
{
//Open connection
conn.Open();
using (System.Data.OleDb.OleDbCommand cmd = new System.Data.OleDb.OleDbCommand())
{
//Build and execute SQL
sql = "INSERT INTO dbo.OPPQUOTEATTACH_TEMP (OPPQUOTEID, FILENAME) VALUES ('" + oppquoteid + "', '" + fileName + "')";
cmd.Connection = conn;
cmd.CommandText = sql;
cmd.ExecuteNonQuery();
}
}
}
}
catch (Exception x)
{
throw x;
}
}
</script>