Hi Issa,
If you download the code from the link I posted, you will see there is a demo that saves the data to an access database, you should be able to get this to work with sql server no problem.
As far as doing it with JavaScript goes,
AFAIK there is no equivalent to VBScript CharB method that is critical to the upload process, so you'll need to either use some VBScript or use a COM object of some sort.
I managed to get the demo to work with code *mainly* in JavaScript by replacing the ToDatabase.asp page with the following...
Code:
<script language="VbScript" runat="Server">
Call DoJs(New clsUpload)
Function GetChrB(pCharCode)
GetChrB = ChrB(pCharCode)
End Function
</script>
<script language="JavaScript" runat="Server">
function DoJs(pClsUpload){
// Grab the file name
var fileName = pClsUpload.Fields("File1").FileName;
var conn = Server.CreateObject("ADODB.Connection");
var rs = Server.CreateObject("ADODB.Recordset");
conn.Open("DRIVER=Microsoft Access Driver (*.mdb);DBQ=" + Server.MapPath("Files.mdb"));
//conn.Open("PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source=" + Server.MapPath("Files.mdb"));
rs.Open("Files", conn, 3, 3);
rs.AddNew();
rs.Fields("FileName").Value = pClsUpload.Fields("File1").FileName;
rs.Fields("FileSize").Value = pClsUpload.Fields("File1").Length;
rs.Fields("ContentType").Value = pClsUpload.Fields("File1").ContentType;
rs.Fields("BinaryData").AppendChunk(pClsUpload("File1").BLOB + GetChrB(0));
rs.Update();
rs.Close();
rs.Open("SELECT Max(FileID) AS ID FROM Files", conn, 3, 3);
var fileId = rs.Fields("ID").Value;
rs.Close();
rs = null;
conn.Close()
conn = null;
pClsUpload = null;
Response.Write("<a href=\"DataFile.asp?FileID=" + fileId + "\">" + fileName + "</a>");
}
</script>
HTH,
Chris