Link to home
Start Free TrialLog in
Avatar of vsshah
vsshah

asked on

How to Upload .jpg file (stored at server Hard Disk) to Database using ASP.

Hi,

With the help of https://www.experts-exchange.com, I am able to do following.
1. Select file(through browser) at client machine, and upload that .jpg file in to SQL Server database.
2. Select file(through browser) at client machine, and upload it Server Hard disk.
3. Get image from database, and display it to .ASP page report.
4. I did all above and following things in Visual Basic/VBA/Ms Access also. but ASP is something new.

My question is as below.
I am using ASP+VBScript. My Company's one Department user(client machine) wants to select any .BMP file thru Browser from their own machine and want to save it to SQL Server Database. SQL Server database is located at Server Hard Disk. I have divided this issue in 5 steps.
1. Open browser and select .BMP file from user's client machine. I mean,  User will select the file from Browser and hit UPLoad button.
2. Copy This .BMP file to Server Hard Disk.
3. Convert .BMP file to .JPG at Server Hard Disk and store it.
4. Upload this .JPG file to SQL Server Database
5. Delete temporary created .JPG, .BMP file from Server Hard Disk.

I am able to all above except Step# 4. how to do it ??

I have gone through http://www.stardeveloper.com/articles/display.html?article=2001033101&page=1

Thanks,


Avatar of jmelika
jmelika

I think you've added extra steps for yourself.  Uploading the file(s) to the hard drive of the server using FileSystemObject is one way, another is to stream the file into the database directly.

I am assuming you already have the database setup to accept the file.  What is the database field type that will hold that data?  Is it binary or image?

Look into GetChunk function of ASP.  It's the most commonly used function for uploading binary files (images included) to database directly.

That will save you step 2 and 3.

JM
Avatar of vsshah

ASKER

thanks for reply.

My field type in table in IMAGE. I need step 2 and 3. Because, I dont want to Upload .BMP file in to database. It is too big. So, I have to convert it in to .jpg.

Code for 'Select file(through browser) at client machine, and upload that .jpg file in to SQL Server database' is as below. It takes file from browser and then upload it to database. While I want to pick up file from Server hard disk and upload it to database.

----
insert.asp

<!--#include file="Loader.asp"-->
<%
      Response.Buffer = True

      ' load object
      Dim load
            Set load = new Loader
            
            ' calling initialize method
            load.initialize
            
      ' File binary data
      Dim fileData
            fileData = load.getFileData("file")
      ' File name
      Dim fileName
            fileName = LCase(load.getFileName("file"))
      ' File path
      Dim filePath
            filePath = load.getFilePath("file")
      ' File path complete
      Dim filePathComplete
            filePathComplete = load.getFilePathComplete("file")
      ' File size
      Dim fileSize
            fileSize = load.getFileSize("file")
      ' File size translated
      Dim fileSizeTranslated
            fileSizeTranslated = load.getFileSizeTranslated("file")
      ' Content Type
      Dim contentType
            contentType = load.getContentType("file")
      ' No. of Form elements
      Dim countElements
            countElements = load.Count
      ' Value of text input field "fname"
      Dim fnameInput
            fnameInput = load.getValue("fname")
      ' Value of text input field "lname"
      Dim lnameInput
            lnameInput = load.getValue("lname")
      ' Value of text input field "profession"
      Dim profession
            profession = load.getValue("profession")      
            
      ' destroying load object
      Set load = Nothing
%>

<html>
<head>
      <title>Inserts Images into Database</title>
      <style>
            body, input, td { font-family:verdana,arial; font-size:10pt; }
      </style>
</head>
<body>
      <p align="center">
            <b>Inserting Binary Data into Database</b><br>
            <a href="show.asp">To see inserted data click here</a>
      </p>
      
<%
      CartName = Request.QueryString("CartName")
      CustId = Request.QueryString("CustId")
      CustPlant = Request.QueryString("CustPlant")
      
%>
      
      
      <table width="700" border="1" align="center">
      <tr>
            <td>File Name</td><td><%= fileName %></td>
      </tr><tr>
            <td>File Path</td><td><%= filePath %></td>
      </tr><tr>
            <td>File Path Complete</td><td><%= filePathComplete %></td>
      </tr><tr>
            <td>File Size</td><td><%= fileSize %></td>
      </tr><tr>
            <td>File Size Translated</td><td><%= fileSizeTranslated %></td>
      </tr><tr>
            <td>Content Type</td><td><%= contentType %></td>
      </tr><tr>
            <td>No. of Form Elements</td><td><%= countElements %></td>
      </tr>
      </table><br><br>
      
      <p style="padding-left:220;">
      <%= fileName %> data received ...<br>

      <%
            ' Checking to make sure if file was uploaded
            If fileSize > 0 Then
            
                  ' Connection string
                  Dim connStr
                        set connStr = Server.CreateObject("ADODB.Connection")                  
                        connStr.open =  "dsn=Test_UGN_DB_DSN;uid=sa;pwd=arihant;"
            
                  ' Recordset object
                  Dim rs
                        Set rs = Server.CreateObject("ADODB.Recordset")
                        
                        sqltext = "select cartname, contenttypepicture3, Picture3Size, Picture3 from Cart_M where CartName = '" & CartName & "' and Cart_M.CustId = " & CustId & " and Cart_M.CustPlant = '" & CustPlant & "'"
                    rs.Open sqltext, connStr, 2, 4
                        
                        
                        ' Adding data
                        rs("Picture3Size") = fileSize
                        rs("Picture3").AppendChunk fileData
                        rs("contenttypepicture3") = contentType
                        rs.UpdateBatch
                        
                        rs.Close
                        Set rs = Nothing
                        
                  Response.Write "<font color=""green"">File was successfully uploaded...</font>"
            Else
                  Response.Write "<font color=""brown"">No file was selected for uploading...</font>"
            End If
                  
                  
            If Err.number <> 0 Then
                  Response.Write "<br><font color=""red"">Something went wrong...</font>"
            End If
            
            response.redirect("Picture_Upload.asp?CartName=" & CartName & "&CustId=" & CustId & "&CustPlant=" & CustPlant )
            
      %>
      </p>

      <br>

</body>
</html>

--------------------

Picture_Upload.asp


<%@LANGUAGE="VBSCRIPT"%>
<!-- #include file="UploadFile.asp" -->
<!-- #include file="../Connections/UGN_DB.asp" -->
<script language = "JavaScript">

function isDigit(theDigit)
{
var digitArray = new Array('0','1','2','3','4','5','6','7','8','9'),j;

for (j = 0; j < digitArray.length; j++)
{if (theDigit == digitArray[j])
return true
}
return false

}
/*************************************************************************/
/*Function name :isPositiveInteger(theString) */
/*Usage of this function :test for an +ve integer */
/*Input parameter required:thedata=string for test whether is +ve integer*/
/*Return value :if is +ve integer,return true */
/* else return false */
/*function require :isDigit */
/*************************************************************************/
function isPositiveInteger(theString)
{
var theData = new String(theString)

if (!isDigit(theData.charAt(0)))
if (!(theData.charAt(0)== '+'))
return false

for (var i = 1; i < theData.length; i++)
if (!isDigit(theData.charAt(i)))
return false
return true
}
/**********************************************************************/
/*Function name :isDate(s,f) */
/*Usage of this function :To check s is a valid format */
/*Input parameter required:s=input string */
/* f=input string format */
/* =1,in mm/dd/yyyy format */
/* else in dd/mm/yyyy */
/*Return value :if is a valid date return 1 */
/* else return 0 */
/*Function required :isPositiveInteger() */
/**********************************************************************/
function isDate(s,f)
{
      var a1=s.split("/");
      var a2=s.split("-");
      var e=true;
      if ((a1.length!=3) && (a2.length!=3))
      {
            e=false;
      }
      else
            {if (a1.length==3)
            var na=a1;
            if (a2.length==3)
            var na=a2;
            if (isPositiveInteger(na[0]) && isPositiveInteger(na[1]) && isPositiveInteger(na[2]))
            { if (f==1)
            {var d=na[1],m=na[0];
            }
            else
            {var d=na[0],m=na[1];
            }
            var y=na[2];
            if (((e) && (y<1000)||y.length>4))
                  e=false
                  if (e)
                  {
v=new Date(m+"/"+d+"/"+y);
if (v.getMonth()!=m-1)
e=false;
}
}
else
{
e=false;
}
}
return e
}

function CheckDate(v)
{
      var s=v.value;

      if (!(s == ""))      
      {
            if (!(isDate(s,1))) //dd/mm/yyyy format
            {      
                  alert("The inputed date value is not valid. Please Enter date in mm/dd/yyyy format");
                  document.form1.CartName.focus();      
                  v.value = "";
                  v.focus();
                  return false;                   
            }
      }      
      
}

function CheckGrossWeight(v)
{
      var s=v.value;

            if (isNaN(s))
            {
                  alert("Please enter Gross Weight using numeric characters only! Your entered value '" + s + "' is not numeric.");
                  document.form1.CartName.focus();      
                  v.value = "";                   
                  v.focus();
                  return false;
            }
}

function CheckQtyPacked(v)
{
      var s=v.value;

            if (isNaN(s))
            {
                  alert("Please enter Qty Packed using numeric characters only! Your entered value '" + s + "' is not numeric.");
                  //document.form2.qtypacked.focus();      
                  v.value = "";                   
                  v.focus();
                  return false;
            }
}

function deletebuttonclick(msg)
{
      //confirm(msg);
      var x=window.confirm(msg)
      if (x)
      {
            location.href = "Cart_Delete.asp?" + document.form1.MM_QueryString.value;
            return true;
      }
      else
      {
            //alert("Not Agree");  
      }
}

function uploadbuttonclick(uploadedfile)
{
      alert("uploadedfile = " + uploadedfile.value );
      newWindow = window.open();
      newWindow.location.href = "Picture_Upload_Action.asp?" + "<%=Request.QueryString%>" + "&uploadedfile=" + uploadedfile.value;

}

function previewbuttonclick()
{
      newWindow = window.open();
      newWindow.location.href = "rpt_packaging_layout.asp?CartName=" + document.form1.CartName.value + "&CustId=" + document.form1.CustId.value + "&CustPlant=" + document.form1.CustPlant.value;
}

function checkfiletype(thevalue)
{
  var regx = new RegExp(".jpg$","i")
  if (regx.test(thevalue))
  {
    //alert("Cool")
      return true;      
  }
  else
  {
    alert("Please Select only .jpg fles")
      document.form2.Submit2.focus;
      document.form2.file.value = "";
      thevalue.focus;
      return false;
  }
}

function filetypecheck()
{
  var regx = new RegExp(".jpg$","i")
  if (regx.test(document.form2.file.value))
  {
    //alert("Cool")
      return true;      
  }
  else
  {
    alert("Please Select only .jpg fles")
      return false;
  }

}

function checkfields()
{
      var num = document.form1.elements.length

      var localpcks002 = "<%=session("PCKS002")%>"; //NEW CONTAINER Entry
      var ugnDeptNo        = "<%=session("MM_UGNDeptNo")%>"; // Dept # 6 - Packaging
      var ugnUserId        = "<%=session("MM_UserId")%>"; //EmpId of User

      //alert("localpcks001 = " + localpcks001 + ", ugnDeptNo = " + ugnDeptNo + ", ugnUserId = " + ugnUserId );

      for (var i=0; i<num;i++)
      {

            if ( localpcks002 == "E" )       //Packaging Dept user will have EDIT rights
            {
                  document.form1.elements[i].disabled = false;            
            }
            else //// Select/ReadOnly. None of above condition satisfied then disable all fields.
            {
                  document.form1.elements[i].disabled = true;            
            }

      }      
      
} // end of function checkfields()

function checkfieldsform2()
{
      var num = document.form2.elements.length

      var localpcks002 = "<%=session("PCKS002")%>"; //NEW CONTAINER Entry
      var ugnDeptNo        = "<%=session("MM_UGNDeptNo")%>"; // Dept # 6 - Packaging
      var ugnUserId        = "<%=session("MM_UserId")%>"; //EmpId of User

      //alert("localpcks001 = " + localpcks001 + ", ugnDeptNo = " + ugnDeptNo + ", ugnUserId = " + ugnUserId );

      for (var i=0; i<num;i++)
      {

            if ( localpcks002 == "E" )       //Packaging Dept user will have EDIT rights
            {
                  document.form2.elements[i].disabled = false;            
            }
            else //// Select/ReadOnly. None of above condition satisfied then disable all fields.
            {
                  document.form2.elements[i].disabled = true;            
            }

      }      
      
} // end of function checkfieldsform2()



</script>

<%
' *** Logout the current user.
MM_Logout = CStr(Request.ServerVariables("URL")) & "?MM_Logoutnow=1"
If (CStr(Request("MM_Logoutnow")) = "1") Then
  Session.Contents.Remove("MM_Username")
  Session.Contents.Remove("MM_UserAuthorization")
  MM_logoutRedirectPage = "../ugndb_login.asp"
  ' redirect with URL parameters (remove the "MM_Logoutnow" query param).
  if (MM_logoutRedirectPage = "") Then MM_logoutRedirectPage = CStr(Request.ServerVariables("URL"))
  If (InStr(1, UC_redirectPage, "?", vbTextCompare) = 0 And Request.QueryString <> "") Then
    MM_newQS = "?"
    For Each Item In Request.QueryString
      If (Item <> "MM_Logoutnow") Then
        If (Len(MM_newQS) > 1) Then MM_newQS = MM_newQS & "&"
        MM_newQS = MM_newQS & Item & "=" & Server.URLencode(Request.QueryString(Item))
      End If
    Next
    if (Len(MM_newQS) > 1) Then MM_logoutRedirectPage = MM_logoutRedirectPage & MM_newQS
  End If
  Response.Redirect(MM_logoutRedirectPage)
End If
%>

<%
' *** Edit Operations: declare variables

Dim MM_editAction
Dim MM_abortEdit
Dim MM_editQuery
Dim MM_editCmd

Dim MM_editConnection
Dim MM_editTable
Dim MM_editRedirectUrl
Dim MM_editColumn
Dim MM_recordId

Dim MM_fieldsStr
Dim MM_columnsStr
Dim MM_fields
Dim MM_columns
Dim MM_typeArray
Dim MM_formVal
Dim MM_delim
Dim MM_altVal
Dim MM_emptyVal
Dim MM_i

MM_editAction = CStr(Request.ServerVariables("SCRIPT_NAME"))
If (Request.QueryString <> "") Then
  MM_editAction = MM_editAction & "?" & Server.HTMLEncode(Request.QueryString)
End If

' boolean to abort record edit
MM_abortEdit = false

' query string to execute
MM_editQuery = ""
%>
<%
' *** Update Record: set variables

If (CStr(Request("MM_update")) = "form1" And CStr(Request("MM_recordId")) <> "") Then

  MM_editConnection = MM_UGN_DB_STRING
  MM_editTable = "dbo.Cart_M"
  MM_editColumn = "CartName"
  MM_recordId = "'" + Request.Form("MM_recordId") + "'"
  MM_editRedirectUrl = "Picture_Upload.asp"
  MM_fieldsStr  = "CartName|value|ContainerNo|value|CustId|value|CustPlant|value|modelyear|value|Model|value|UGNFacility|value|UGNDeptNo|value|RevisionDate|value|EmpId|value|SingleMultiPartFlag|value|GrossWeight|value|IsPublished|value"
  MM_columnsStr = "CartName|',none,''|ContainerNo|',none,''|CustId|none,none,NULL|CustPlant|',none,''|ModelYear|none,none,NULL|Model|',none,''|UGNFacility|none,none,NULL|UGNDeptNo|none,none,NULL|RevisionDate|',none,NULL|EmpId|none,none,NULL|SingleMultiPartFlag|',none,''|GrossWeight|none,none,NULL|IsPublished|none,none,NULL"

  ' create the MM_fields and MM_columns arrays
  MM_fields = Split(MM_fieldsStr, "|")
  MM_columns = Split(MM_columnsStr, "|")
 
  ' set the form values
  For MM_i = LBound(MM_fields) To UBound(MM_fields) Step 2
    MM_fields(MM_i+1) = CStr(Request.Form(MM_fields(MM_i)))
  Next

  ' append the query string to the redirect URL
  If (MM_editRedirectUrl <> "" And Request.QueryString <> "") Then
    If (InStr(1, MM_editRedirectUrl, "?", vbTextCompare) = 0 And Request.QueryString <> "") Then
      MM_editRedirectUrl = MM_editRedirectUrl & "?" & Request.QueryString
    Else
      MM_editRedirectUrl = MM_editRedirectUrl & "&" & Request.QueryString
    End If
  End If

End If
%>
<%
' *** Update Record: construct a sql update statement and execute it

If (CStr(Request("MM_update")) <> "" And CStr(Request("MM_recordId")) <> "") Then

  ' create the sql update statement
  MM_editQuery = "update " & MM_editTable & " set "
  For MM_i = LBound(MM_fields) To UBound(MM_fields) Step 2
    MM_formVal = MM_fields(MM_i+1)
    MM_typeArray = Split(MM_columns(MM_i+1),",")
    MM_delim = MM_typeArray(0)
    If (MM_delim = "none") Then MM_delim = ""
    MM_altVal = MM_typeArray(1)
    If (MM_altVal = "none") Then MM_altVal = ""
    MM_emptyVal = MM_typeArray(2)
    If (MM_emptyVal = "none") Then MM_emptyVal = ""
    If (MM_formVal = "") Then
      MM_formVal = MM_emptyVal
    Else
      If (MM_altVal <> "") Then
        MM_formVal = MM_altVal
      ElseIf (MM_delim = "'") Then  ' escape quotes
        MM_formVal = "'" & Replace(MM_formVal,"'","''") & "'"
      Else
        MM_formVal = MM_delim + MM_formVal + MM_delim
      End If
    End If
    If (MM_i <> LBound(MM_fields)) Then
      MM_editQuery = MM_editQuery & ","
    End If
    MM_editQuery = MM_editQuery & MM_columns(MM_i) & " = " & MM_formVal
  Next
  MM_editQuery = MM_editQuery & " where " & MM_editColumn & " = " & MM_recordId

  If (Not MM_abortEdit) Then
    ' execute the update
    Set MM_editCmd = Server.CreateObject("ADODB.Command")
    MM_editCmd.ActiveConnection = MM_editConnection
    MM_editCmd.CommandText = MM_editQuery
    MM_editCmd.Execute
    MM_editCmd.ActiveConnection.Close

    If (MM_editRedirectUrl <> "") Then
      Response.Redirect(MM_editRedirectUrl)
    End If
  End If

End If
%>
<%
Dim Cart_M__vCartName
Cart_M__vCartName = "%"
If (Request.QueryString("CartName")  <> "") Then
  Cart_M__vCartName = Request.QueryString("CartName")
End If
%>
<%
Dim Cart_M__vCustId
Cart_M__vCustId = "0"
If (Request.QueryString("CustId")  <> "") Then
  Cart_M__vCustId = Request.QueryString("CustId")
End If
%>
<%
Dim Cart_M__VCustPlant
Cart_M__VCustPlant = "%"
If (Request.QueryString("CustPlant")   <> "") Then
  Cart_M__VCustPlant = Request.QueryString("CustPlant")  
End If
%>
<%
Dim Cart_M
Dim Cart_M_numRows

Set Cart_M = Server.CreateObject("ADODB.Recordset")
Cart_M.ActiveConnection = MM_UGN_DB_STRING
Cart_M.Source = "SELECT CartName, ContainerNo, RevisionDate, CustId, CustPlant, Model, ModelYear, EmpId, GrossWeight, IsPublished, UGNFacility, UGNDeptNo, SingleMultiPartFlag  FROM Cart_M  WHERE Cart_M.CartName = '" + Replace(Cart_M__vCartName, "'", "''") + "' and Cart_M.CustId = '" + Replace(Cart_M__vCustId, "'", "''") + "' and Cart_M.CustPlant = '" + Replace(Cart_M__VCustPlant, "'", "''") + "'  ORDER BY Cart_M.CartName"      
'response.write("Cart_M.Source = " & Cart_M.Source)
'response.end
Cart_M.CursorType = 0
Cart_M.CursorLocation = 2
Cart_M.LockType = 1
Cart_M.Open()

Cart_M_numRows = 0
%>
<%
Dim Cust_M
Dim Cust_M_numRows

Set Cust_M = Server.CreateObject("ADODB.Recordset")
Cust_M.ActiveConnection = MM_UGN_DB_STRING
Cust_M.Source = "SELECT Cust_M.CustId, Cust_M.CustName FROM Cust_M ORDER BY CustName "
Cust_M.CursorType = 0
Cust_M.CursorLocation = 2
Cust_M.LockType = 1
Cust_M.Open()

Cust_M_numRows = 0
%>
<%
Dim Cust_Plant_M
Dim Cust_Plant_M_numRows

Set Cust_Plant_M = Server.CreateObject("ADODB.Recordset")
Cust_Plant_M.ActiveConnection = MM_UGN_DB_STRING
Cust_Plant_M.Source = "SELECT Cust_Plant_M.CustPlant, Cust_M.CustName + '-> ' + Cust_Plant_M.CustPlant as CustPlantName FROM Cust_M, Cust_Plant_M Where Cust_M.CustId = Cust_Plant_M.CustId ORDER BY Cust_M.CustName, Cust_Plant_M.CustPlant  "
Cust_Plant_M.CursorType = 0
Cust_Plant_M.CursorLocation = 2
Cust_Plant_M.LockType = 1
Cust_Plant_M.Open()

Cust_Plant_M_numRows = 0
%>
<%
Dim Employee_M
Dim Employee_M_numRows

Set Employee_M = Server.CreateObject("ADODB.Recordset")
Employee_M.ActiveConnection = MM_UGN_DB_STRING
Employee_M.Source = "SELECT EmpId, EmplastName + ', ' + EmpFirstName AS EmpName  FROM Employee_M  WHERE EmpStatus='Working'  ORDER BY EmplastName +' '+ EmpFirstName"
Employee_M.CursorType = 0
Employee_M.CursorLocation = 2
Employee_M.LockType = 1
Employee_M.Open()

Employee_M_numRows = 0
%>
<%
Dim Container_M
Dim Container_M_numRows

Set Container_M = Server.CreateObject("ADODB.Recordset")
Container_M.ActiveConnection = MM_UGN_DB_STRING
Container_M.Source = "SELECT Container_M.ContainerNo  FROM Container_M  ORDER BY Container_M.ContainerNo"
Container_M.CursorType = 0
Container_M.CursorLocation = 2
Container_M.LockType = 1
Container_M.Open()

Container_M_numRows = 0
%>
<%
Dim UGN_Facility_M
Dim UGN_Facility_M_numRows

Set UGN_Facility_M = Server.CreateObject("ADODB.Recordset")
UGN_Facility_M.ActiveConnection = MM_UGN_DB_STRING
UGN_Facility_M.Source = "Select UGNFacility, UGNFacilityName from UGN_Facility_M Where UGNFacility < 15 Order By UGNFacility"
UGN_Facility_M.CursorType = 0
UGN_Facility_M.CursorLocation = 2
UGN_Facility_M.LockType = 1
UGN_Facility_M.Open()

UGN_Facility_M_numRows = 0
%>
<%
Dim UGN_Dept_M
Dim UGN_Dept_M_numRows

Set UGN_Dept_M = Server.CreateObject("ADODB.Recordset")
UGN_Dept_M.ActiveConnection = MM_UGN_DB_STRING
UGN_Dept_M.Source = "Select UGNDeptNo, UGNDeptName from UGN_Dept_M Where UGNDeptNo > 0 Order By UGNDeptName"
UGN_Dept_M.CursorType = 0
UGN_Dept_M.CursorLocation = 2
UGN_Dept_M.LockType = 1
UGN_Dept_M.Open()

UGN_Dept_M_numRows = 0
%>
<html><!-- InstanceBegin template="file:///C|/Inetpub/wwwroot/Main Menu/Templates/temp_red.dwt" codeOutsideHTMLIsLocked="false" -->
<head>
<!-- InstanceBeginEditable name="doctitle" -->
<title>Instruction List</title>
<!-- InstanceEndEditable -->
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<!-- InstanceBeginEditable name="head" --><!-- InstanceEndEditable -->
<script language="JavaScript">
<!--
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
//-->
<!--
function TJK_noWayBack(){// http://www.MadCoWWWebDesign.com - Thierry Koblentz
 history.go(1);
}
TJK_noWayBack();
//-->
</script>
</head>
<body bgcolor="#FFFFFF" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" onLoad="TJK_noWayBack()">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td rowspan="2" bgcolor="#666666"> <img src="http://ugndb/onTrack/images/luxury.png" name="image" width="125" height="50">
    </td>
    <td width="100%" bgcolor="#CCCCCC"><font color="#de192b" size="1" face="Verdana, Arial, Helvetica, sans-serif">
      <strong>UGN, Inc.</strong></font></td>
  </tr>
  <tr>
    <td align="left" valign="bottom" bgcolor="#CCCCCC"><strong><font size="-1">Your
          logged in as <font color="#de192b" size="1" face="Verdana, Arial, Helvetica, sans-serif">
      <strong><%=Session("MM_UserName")%></strong></font> .</font></strong></td>
  </tr>
</table>
<!-- InstanceBeginEditable name="Body" -->
<table width="100%" border="0" cellspacing="2" cellpadding="4" align="center">
  <tr bgcolor="#333333">
    <td width="12%"><table width="100%" border="0" cellspacing="0" cellpadding="4">
        <tr>
          <td nowrap bgcolor="#de192b"><font color="#CCCCCC" size="1"><b>Quick
                Links</b></font></td>
        </tr>
      </table>
    </td>
    <td width="88%">
      <table width="100%" border="0" cellspacing="0" cellpadding="4">
        <tr>
          <td bgcolor="#de192b">&nbsp;&nbsp;</td>
          <td width="100%"> <font color="#CCCCCC"> <b>Create/Modify Packaging
                Layout</b></font></td>
        </tr>
      </table>
    </td>
  </tr>
</table>
<table width="123%" border="0" cellspacing="4" cellpadding="4" align="center">
  <tr>
    <td width="12%" valign="top">
    <table>
      <tr>
        <td height="21"><a href="Packaging_Module_Menu.asp"><img src="../images/pkgm.gif" width="108" height="19" border="0"></a></td>
      </tr>
      <tr>
        <td>&nbsp;</td>
      </tr>
      <tr>
        <td>&nbsp;</td>
      </tr>
      <tr>
        <td><hr>
        </td>
      </tr>
      <tr>
        <td><strong><a href="http://ugndb/ugnmainmenu/Main_Menu.asp?<%="UgnFacility=" &  Session("MM_EmpUGNfacility") %>"><img src="../images/bugn.gif" width="108" height="29" border="0"></a></strong></td>
      </tr>
      <tr>
        <td><strong><font size="-1"><a href="<%= MM_Logout %>"><img src="../images/bso.gif" width="108" height="18" border="0"></a></font></strong></td>
      </tr>
    </table>
    <p><strong></strong></p>      <strong></strong><strong></strong><strong></strong><strong></strong><strong><font color="#000000">&nbsp;</font></strong></td>
    <td width="88%" valign="top"> <table width="79%" border="0">
      <tr>
        <td bordercolor="#FFFFFF">
          <form METHOD="POST" name="form1" action="<%=MM_editAction%>">
            <table width="715" border="0">
              <tr>
                <td width="124"><div align="right"><strong><font size="-1"><font color="#990000">*</font>Part Number :</font></strong></div></td>
                <td width="182"><input name="CartName" type="text" id="CartName" value="<%=(Cart_M.Fields.Item("CartName").Value)%>"></td>
                <td width="103"><div align="right"><strong><font size="-1">Container No: </font></strong></div></td>
                <td width="212"><select name="ContainerNo" id="ContainerNo">
                  <option value="" <%If (Not isNull((Cart_M.Fields.Item("ContainerNo").Value))) Then If ("" = CStr((Cart_M.Fields.Item("ContainerNo").Value))) Then Response.Write("SELECTED") : Response.Write("")%>></option>
                  <%
While (NOT Container_M.EOF)
%>
                  <option value="<%=(Container_M.Fields.Item("ContainerNo").Value)%>" <%If (Not isNull((Cart_M.Fields.Item("ContainerNo").Value))) Then If (CStr(Container_M.Fields.Item("ContainerNo").Value) = CStr((Cart_M.Fields.Item("ContainerNo").Value))) Then Response.Write("SELECTED") : Response.Write("")%> ><%=(Container_M.Fields.Item("ContainerNo").Value)%></option>
                    <%
  Container_M.MoveNext()
Wend
If (Container_M.CursorType > 0) Then
  Container_M.MoveFirst
Else
  Container_M.Requery
End If
%>
                </select></td>
              </tr>
              <tr>
                <td><div align="right"><strong><font size="-1"><font color="#990000">*</font>Customer: </font></strong></div></td>
                <td><select name="CustId" id="CustId" onchange="custplantrefresh()">
                  <option value="" <%If (Not isNull((Cart_M.Fields.Item("CustId").Value))) Then If ("" = CStr((Cart_M.Fields.Item("CustId").Value))) Then Response.Write("SELECTED") : Response.Write("")%>></option>
                  <%
While (NOT Cust_M.EOF)
%>
                  <option value="<%=(Cust_M.Fields.Item("CustId").Value)%>" <%If (Not isNull((Cart_M.Fields.Item("CustId").Value))) Then If (CStr(Cust_M.Fields.Item("CustId").Value) = CStr((Cart_M.Fields.Item("CustId").Value))) Then Response.Write("SELECTED") : Response.Write("")%> ><%=(Cust_M.Fields.Item("CustName").Value)%></option>
                    <%
  Cust_M.MoveNext()
Wend
If (Cust_M.CursorType > 0) Then
  Cust_M.MoveFirst
Else
  Cust_M.Requery
End If
%>
                </select></td>
                <td><div align="right"><strong><font size="-1"><font color="#990000">*</font>Customer Plant:</font></strong></div></td>
                <td><select name="CustPlant" id="CustPlant">
                  <option value="" <%If (Not isNull((Cart_M.Fields.Item("CustPlant").Value))) Then If ("" = CStr((Cart_M.Fields.Item("CustPlant").Value))) Then Response.Write("SELECTED") : Response.Write("")%>></option>
                  <%
While (NOT Cust_Plant_M.EOF)
%>
                  <option value="<%=(Cust_Plant_M.Fields.Item("CustPlant").Value)%>" <%If (Not isNull((Cart_M.Fields.Item("CustPlant").Value))) Then If (CStr(Cust_Plant_M.Fields.Item("CustPlant").Value) = CStr((Cart_M.Fields.Item("CustPlant").Value))) Then Response.Write("SELECTED") : Response.Write("")%> ><%=(Cust_Plant_M.Fields.Item("CustPlantName").Value)%></option>
                    <%
  Cust_Plant_M.MoveNext()
Wend
If (Cust_Plant_M.CursorType > 0) Then
  Cust_Plant_M.MoveFirst
Else
  Cust_Plant_M.Requery
End If
%>
                </select></td>
              </tr>
              <tr>
                <td><div align="right"><strong><font size="-1">Model Year:</font></strong></div></td>
                <td><select name="modelyear">
                  <option value=""  <%If (Not isNull((Cart_M.Fields.Item("ModelYear").Value))) Then If ("" = CStr((Cart_M.Fields.Item("ModelYear").Value))) Then Response.Write("SELECTED") : Response.Write("")%>></option>
                  <option value="1991"  <%If (Not isNull((Cart_M.Fields.Item("ModelYear").Value))) Then If ("1991" = CStr((Cart_M.Fields.Item("ModelYear").Value))) Then Response.Write("SELECTED") : Response.Write("")%>>1991</option>
                    <option value="1992"  <%If (Not isNull((Cart_M.Fields.Item("ModelYear").Value))) Then If ("1992" = CStr((Cart_M.Fields.Item("ModelYear").Value))) Then Response.Write("SELECTED") : Response.Write("")%>>1992</option>
                    <option value="1993"  <%If (Not isNull((Cart_M.Fields.Item("ModelYear").Value))) Then If ("1993" = CStr((Cart_M.Fields.Item("ModelYear").Value))) Then Response.Write("SELECTED") : Response.Write("")%>>1993</option>
                    <option value="1994"  <%If (Not isNull((Cart_M.Fields.Item("ModelYear").Value))) Then If ("1994" = CStr((Cart_M.Fields.Item("ModelYear").Value))) Then Response.Write("SELECTED") : Response.Write("")%>>1994</option>
                    <option value="1995"  <%If (Not isNull((Cart_M.Fields.Item("ModelYear").Value))) Then If ("1995" = CStr((Cart_M.Fields.Item("ModelYear").Value))) Then Response.Write("SELECTED") : Response.Write("")%>>1995</option>
                    <option value="1996"  <%If (Not isNull((Cart_M.Fields.Item("ModelYear").Value))) Then If ("1996" = CStr((Cart_M.Fields.Item("ModelYear").Value))) Then Response.Write("SELECTED") : Response.Write("")%>>1996</option>
                    <option value="1997"  <%If (Not isNull((Cart_M.Fields.Item("ModelYear").Value))) Then If ("1997" = CStr((Cart_M.Fields.Item("ModelYear").Value))) Then Response.Write("SELECTED") : Response.Write("")%>>1997</option>
                    <option value="1998"  <%If (Not isNull((Cart_M.Fields.Item("ModelYear").Value))) Then If ("1998" = CStr((Cart_M.Fields.Item("ModelYear").Value))) Then Response.Write("SELECTED") : Response.Write("")%>>1998</option>
                    <option value="1999"  <%If (Not isNull((Cart_M.Fields.Item("ModelYear").Value))) Then If ("1999" = CStr((Cart_M.Fields.Item("ModelYear").Value))) Then Response.Write("SELECTED") : Response.Write("")%>>1999</option>
                    <option value="2000"  <%If (Not isNull((Cart_M.Fields.Item("ModelYear").Value))) Then If ("2000" = CStr((Cart_M.Fields.Item("ModelYear").Value))) Then Response.Write("SELECTED") : Response.Write("")%>>2000</option>
                    <option value="2001"  <%If (Not isNull((Cart_M.Fields.Item("ModelYear").Value))) Then If ("2001" = CStr((Cart_M.Fields.Item("ModelYear").Value))) Then Response.Write("SELECTED") : Response.Write("")%>>2001</option>
                    <option value="2002"  <%If (Not isNull((Cart_M.Fields.Item("ModelYear").Value))) Then If ("2002" = CStr((Cart_M.Fields.Item("ModelYear").Value))) Then Response.Write("SELECTED") : Response.Write("")%>>2002</option>
                    <option value="2003"  <%If (Not isNull((Cart_M.Fields.Item("ModelYear").Value))) Then If ("2003" = CStr((Cart_M.Fields.Item("ModelYear").Value))) Then Response.Write("SELECTED") : Response.Write("")%>>2003</option>
                    <option value="2004"  <%If (Not isNull((Cart_M.Fields.Item("ModelYear").Value))) Then If ("2004" = CStr((Cart_M.Fields.Item("ModelYear").Value))) Then Response.Write("SELECTED") : Response.Write("")%>>2004</option>
                    <option value="2005"  <%If (Not isNull((Cart_M.Fields.Item("ModelYear").Value))) Then If ("2005" = CStr((Cart_M.Fields.Item("ModelYear").Value))) Then Response.Write("SELECTED") : Response.Write("")%>>2005</option>
                    <option value="2006"  <%If (Not isNull((Cart_M.Fields.Item("ModelYear").Value))) Then If ("2006" = CStr((Cart_M.Fields.Item("ModelYear").Value))) Then Response.Write("SELECTED") : Response.Write("")%>>2006</option>
                    <option value="2007"  <%If (Not isNull((Cart_M.Fields.Item("ModelYear").Value))) Then If ("2007" = CStr((Cart_M.Fields.Item("ModelYear").Value))) Then Response.Write("SELECTED") : Response.Write("")%>>2007</option>
                    <option value="2008"  <%If (Not isNull((Cart_M.Fields.Item("ModelYear").Value))) Then If ("2008" = CStr((Cart_M.Fields.Item("ModelYear").Value))) Then Response.Write("SELECTED") : Response.Write("")%>>2008</option>
                    <option value="2009"  <%If (Not isNull((Cart_M.Fields.Item("ModelYear").Value))) Then If ("2009" = CStr((Cart_M.Fields.Item("ModelYear").Value))) Then Response.Write("SELECTED") : Response.Write("")%>>2009</option>
                    <option value="2010"  <%If (Not isNull((Cart_M.Fields.Item("ModelYear").Value))) Then If ("2010" = CStr((Cart_M.Fields.Item("ModelYear").Value))) Then Response.Write("SELECTED") : Response.Write("")%>>2010</option>
                    <option value="2011"  <%If (Not isNull((Cart_M.Fields.Item("ModelYear").Value))) Then If ("2011" = CStr((Cart_M.Fields.Item("ModelYear").Value))) Then Response.Write("SELECTED") : Response.Write("")%>>2011</option>
                    <option value="2012"  <%If (Not isNull((Cart_M.Fields.Item("ModelYear").Value))) Then If ("2012" = CStr((Cart_M.Fields.Item("ModelYear").Value))) Then Response.Write("SELECTED") : Response.Write("")%>>2012</option>
                    <option value="2013"  <%If (Not isNull((Cart_M.Fields.Item("ModelYear").Value))) Then If ("2013" = CStr((Cart_M.Fields.Item("ModelYear").Value))) Then Response.Write("SELECTED") : Response.Write("")%>>2013</option>
                    <option value="2014"  <%If (Not isNull((Cart_M.Fields.Item("ModelYear").Value))) Then If ("2014" = CStr((Cart_M.Fields.Item("ModelYear").Value))) Then Response.Write("SELECTED") : Response.Write("")%>>2014</option>
                    <option value="2015"  <%If (Not isNull((Cart_M.Fields.Item("ModelYear").Value))) Then If ("2015" = CStr((Cart_M.Fields.Item("ModelYear").Value))) Then Response.Write("SELECTED") : Response.Write("")%>>2015</option>
                    <option value="2016"  <%If (Not isNull((Cart_M.Fields.Item("ModelYear").Value))) Then If ("2016" = CStr((Cart_M.Fields.Item("ModelYear").Value))) Then Response.Write("SELECTED") : Response.Write("")%>>2016</option>
                    <option value="2017"  <%If (Not isNull((Cart_M.Fields.Item("ModelYear").Value))) Then If ("2017" = CStr((Cart_M.Fields.Item("ModelYear").Value))) Then Response.Write("SELECTED") : Response.Write("")%>>2017</option>
                    <option value="2018"  <%If (Not isNull((Cart_M.Fields.Item("ModelYear").Value))) Then If ("2018" = CStr((Cart_M.Fields.Item("ModelYear").Value))) Then Response.Write("SELECTED") : Response.Write("")%>>2018</option>
                    <option value="2019"  <%If (Not isNull((Cart_M.Fields.Item("ModelYear").Value))) Then If ("2019" = CStr((Cart_M.Fields.Item("ModelYear").Value))) Then Response.Write("SELECTED") : Response.Write("")%>>2019</option>
                    <option value="2020"  <%If (Not isNull((Cart_M.Fields.Item("ModelYear").Value))) Then If ("2020" = CStr((Cart_M.Fields.Item("ModelYear").Value))) Then Response.Write("SELECTED") : Response.Write("")%>>2020</option>
                </select></td>
                <td><div align="right"><strong><font size="-1">Model:</font></strong></div></td>
                <td><input name="Model" type="text" id="Model" value="<%=(Cart_M.Fields.Item("Model").Value)%>"></td>
              </tr>
              <tr>
                <td><div align="right"><strong><font size="-1">UGN Facility:</font></strong></div></td>
                <td><select name="UGNFacility" id="UGNFacility">
                  <option value="" <%If (Not isNull((Cart_M.Fields.Item("UGNFacility").Value))) Then If ("" = CStr((Cart_M.Fields.Item("UGNFacility").Value))) Then Response.Write("SELECTED") : Response.Write("")%>></option>
                  <%
While (NOT UGN_Facility_M.EOF)
%>
                  <option value="<%=(UGN_Facility_M.Fields.Item("UGNFacility").Value)%>" <%If (Not isNull((Cart_M.Fields.Item("UGNFacility").Value))) Then If (CStr(UGN_Facility_M.Fields.Item("UGNFacility").Value) = CStr((Cart_M.Fields.Item("UGNFacility").Value))) Then Response.Write("SELECTED") : Response.Write("")%> ><%=(UGN_Facility_M.Fields.Item("UGNFacilityName").Value)%></option>
                    <%
  UGN_Facility_M.MoveNext()
Wend
If (UGN_Facility_M.CursorType > 0) Then
  UGN_Facility_M.MoveFirst
Else
  UGN_Facility_M.Requery
End If
%>
                </select></td>
                <td><div align="right"><strong><font size="-1">UGN Department: </font></strong></div></td>
                <td><select name="UGNDeptNo" id="UGNDeptNo">
                  <option value="" <%If (Not isNull((Cart_M.Fields.Item("UGNDeptNo").Value))) Then If ("" = CStr((Cart_M.Fields.Item("UGNDeptNo").Value))) Then Response.Write("SELECTED") : Response.Write("")%>></option>
                  <%
While (NOT UGN_Dept_M.EOF)
%>
                  <option value="<%=(UGN_Dept_M.Fields.Item("UGNDeptNo").Value)%>" <%If (Not isNull((Cart_M.Fields.Item("UGNDeptNo").Value))) Then If (CStr(UGN_Dept_M.Fields.Item("UGNDeptNo").Value) = CStr((Cart_M.Fields.Item("UGNDeptNo").Value))) Then Response.Write("SELECTED") : Response.Write("")%> ><%=(UGN_Dept_M.Fields.Item("UGNDeptName").Value)%></option>
                    <%
  UGN_Dept_M.MoveNext()
Wend
If (UGN_Dept_M.CursorType > 0) Then
  UGN_Dept_M.MoveFirst
Else
  UGN_Dept_M.Requery
End If
%>
                </select></td>
              </tr>
              <tr>
                <td><div align="right"><strong><font size="-1">Revision Date:</font></strong></div></td>
                <td><input name="RevisionDate" type="text" id="RevisionDate" onChange=CheckDate(this.form.RevisionDate) value="<%=(Cart_M.Fields.Item("RevisionDate").Value)%>" ></td>
                <td><div align="right"><strong><font size="-1">Employee:</font></strong></div></td>
                <td><select name="EmpId" >
                  <option value="" <%If (Not isNull((Cart_M.Fields.Item("EmpId").Value))) Then If ("" = CStr((Cart_M.Fields.Item("EmpId").Value))) Then Response.Write("SELECTED") : Response.Write("")%>></option>
                  <%
While (NOT Employee_M.EOF)
%>
                  <option value="<%=(Employee_M.Fields.Item("EmpId").Value)%>" <%If (Not isNull((Cart_M.Fields.Item("EmpId").Value))) Then If (CStr(Employee_M.Fields.Item("EmpId").Value) = CStr((Cart_M.Fields.Item("EmpId").Value))) Then Response.Write("SELECTED") : Response.Write("")%> ><%=(Employee_M.Fields.Item("EmpName").Value)%></option>
                    <%
  Employee_M.MoveNext()
Wend
If (Employee_M.CursorType > 0) Then
  Employee_M.MoveFirst
Else
  Employee_M.Requery
End If
%>
                </select></td>
              </tr>
              <tr>
                <td><div align="right"><strong><font size="-1">Single/Multiple Part :</font></strong></div></td>
                <td><select name="SingleMultiPartFlag" id="SingleMultiPartFlag">
                  <option value="" <%If (Not isNull((Cart_M.Fields.Item("SingleMultiPartFlag").Value))) Then If ("" = CStr((Cart_M.Fields.Item("SingleMultiPartFlag").Value))) Then Response.Write("SELECTED") : Response.Write("")%>></option>
                  <option value="S" <%If (Not isNull((Cart_M.Fields.Item("SingleMultiPartFlag").Value))) Then If ("S" = CStr((Cart_M.Fields.Item("SingleMultiPartFlag").Value))) Then Response.Write("SELECTED") : Response.Write("")%>>Single</option>
                    <option value="M" <%If (Not isNull((Cart_M.Fields.Item("SingleMultiPartFlag").Value))) Then If ("M" = CStr((Cart_M.Fields.Item("SingleMultiPartFlag").Value))) Then Response.Write("SELECTED") : Response.Write("")%>>Multiple</option>
                </select></td>
                <td><div align="right"><strong><font size="-1">Gross Weight: </font></strong></div></td>
                <td><input name="GrossWeight" type="text" id="GrossWeight" onBlur="CheckGrossWeight(this.form.GrossWeight)" value="<%=(Cart_M.Fields.Item("GrossWeight").Value)%>" maxlength="6"></td>
              </tr>
              <tr>
                <td><div align="right"><strong><font size="-1">Is Published:</font></strong></div></td>
                <td><select name="IsPublished" id="IsPublished">
                  <option value="0" <%If (Not isNull((Cart_M.Fields.Item("IsPublished").Value))) Then If ("0" = CStr((Cart_M.Fields.Item("IsPublished").Value))) Then Response.Write("SELECTED") : Response.Write("")%>>No</option>
                  <option value="1" selected  <%If (Not isNull((Cart_M.Fields.Item("IsPublished").Value))) Then If ("1" = CStr((Cart_M.Fields.Item("IsPublished").Value))) Then Response.Write("SELECTED") : Response.Write("")%>>Yes</option>
                </select></td>
                <td>&nbsp;</td>
                <td><div align="right">
                  <input name="previewbutton" type="button" id="previewbutton" value="Preview" onclick="previewbuttonclick()">
                  <input type="submit" name="Submit" onClick="return savebuttonclick()" value="Save">
                  <input type="button" name="Button" onClick="return deletebuttonclick('Part Record to be Deleted?')" value="Delete">
                </div></td>
              </tr>
            </table>
         
            <input type="hidden" name="MM_update" value="form1">
            <input type="hidden" name="MM_recordId" value="<%= Cart_M.Fields.Item("CartName").Value %>">
            <input type="hidden" name="MM_QueryString" value="<%=Request.QueryString%>">
            <%
                        Response.Write ("<script language='JavaScript'>checkfields();</script>")      
                  %>
          </form>    
              </td>
      </tr>
      <tr>
        <td bordercolor="#FFFFFF"><img src="images/picture.png" width="598" height="27" border="0" usemap="#Map">
          <map name="Map">
          <area shape="rect" coords="15,2,95,23" href="Part_Detail_List.asp?CartName=<%=Cart_M("CartName")%>&CustId=<%=Cart_M("CustId")%>&CustPlant=<%=Cart_M("CustPlant")%>">
          <area shape="rect" coords="121,2,210,23" href="Instructions_List.asp?CartName=<%=Cart_M("CartName")%>&CustId=<%=Cart_M("CustId")%>&CustPlant=<%=Cart_M("CustPlant")%>">
          </map>
        </td>
      </tr>
      <tr>
        <td bordercolor="#FFFFFF"><table width="96%" border="1">
          <tr><td height="51"><form name="form2" method="POST" enctype="multipart/form-data" onSubmit="return filetypecheck()" action="Insert.asp?CartName=<%=Request.QueryString("CartName")%>&CustId=<%=Request.QueryString("CustId")%>&CustPlant=<%=Request.QueryString("CustPlant")%>">
                <p>File to Upload: <input name="file" type="file" onchange="checkfiletype(this.value)" size=80><br>                <br>
                        <input name="UploadButton" type="submit" style="margin-top:2" value="Upload" >
                        <input name="Submit2" type="hidden" onClick="MM_goToURL('parent','RFC_Update.asp?RFQNo=<%=Request.QueryString("RFQNo")%>&rf=<%=Request.QueryString("rf")%>&orig=<%=Request.QueryString("orig")%>&qe=<%=Request.QueryString("qe")%>&co=<%=Request.QueryString("co")%>&cd=<%=Request.QueryString("cd")%>&sa=<%=Request.QueryString("sa")%>');return document.MM_returnValue" value="Cancel">
                <%
                              Response.Write ("<script language='JavaScript'>checkfieldsform2();</script>")      
                        %>
                </p>
                <p>
                  <input type="image" border="0" name="imageField" src="file.asp?Cartname=<%=Request.QueryString("Cartname")%>&CustId=<%=Request.QueryString("CustId")%>&CustPlant=<%=Request.QueryString("CustPlant")%>" width="600" height="400" >
                </p>
          </form></td>
          </tr>
        </table>
          <p>&nbsp;</p></td>
      </tr>
    </table>      <p>&nbsp;</p>
    </td>

  </tr>
</table>
<!-- InstanceEndEditable --><br>
<table width="100%" border="0" cellspacing="0" cellpadding="2" bgcolor="#CCCCCC">
  <tr>
    <td width="23%"> <font size="-3" face="Verdana, Arial, Helvetica, sans-serif">&copy;2003
    UGN, Inc. </font></td>
    <td width="77%" align="right">&nbsp;</td>
  </tr>
</table>
</body>
<!-- InstanceEnd --></html>
<%
Cart_M.Close()
Set Cart_M = Nothing
%>
<%
Cust_M.Close()
Set Cust_M = Nothing
%>
<%
Cust_Plant_M.Close()
Set Cust_Plant_M = Nothing
%>
<%
Employee_M.Close()
Set Employee_M = Nothing
%>
<%
Container_M.Close()
Set Container_M = Nothing
%>
<%
UGN_Facility_M.Close()
Set UGN_Facility_M = Nothing
%>
<%
UGN_Dept_M.Close()
Set UGN_Dept_M = Nothing
%>


------

Loader.asp

<%
      ' -- Loader.asp --
      ' -- version 1.5.2
      ' -- last updated 12/5/2002
      '
      ' Faisal Khan
      ' faisal@stardeveloper.com
      ' www.stardeveloper.com
      ' Class for handling binary uploads
      
      Class Loader
            Private dict
            
            Private Sub Class_Initialize
                  Set dict = Server.CreateObject("Scripting.Dictionary")
            End Sub
            
            Private Sub Class_Terminate
                  If IsObject(intDict) Then
                        intDict.RemoveAll
                        Set intDict = Nothing
                  End If
                  If IsObject(dict) Then
                        dict.RemoveAll
                        Set dict = Nothing
                  End If
            End Sub

            Public Property Get Count
                  Count = dict.Count
            End Property

            Public Sub Initialize
                  If Request.TotalBytes > 0 Then
                        Dim binData
                              binData = Request.BinaryRead(Request.TotalBytes)
                              getData binData
                  End If
            End Sub
            
            Public Function getFileData(name)
                  If dict.Exists(name) Then
                        getFileData = dict(name).Item("Value")
                        Else
                        getFileData = ""
                  End If
            End Function

            Public Function getValue(name)
                  Dim gv
                  If dict.Exists(name) Then
                        gv = CStr(dict(name).Item("Value"))
                        
                        gv = Left(gv,Len(gv)-2)
                        getValue = gv
                  Else
                        getValue = ""
                  End If
            End Function
            
            Public Function saveToFile(name, path)
                  If dict.Exists(name) Then
                        Dim temp
                              temp = dict(name).Item("Value")
                        Dim fso
                              Set fso = Server.CreateObject("Scripting.FileSystemObject")
                        Dim file
                              Set file = fso.CreateTextFile(path)
                                    For tPoint = 1 to LenB(temp)
                                        file.Write Chr(AscB(MidB(temp,tPoint,1)))
                                    Next
                                    file.Close
                              saveToFile = True
                  Else
                              saveToFile = False
                  End If
            End Function
            
            Public Function getFileName(name)
                  If dict.Exists(name) Then
                        Dim temp, tempPos
                              temp = dict(name).Item("FileName")
                              tempPos = 1 + InStrRev(temp, "\")
                              getFileName = Mid(temp, tempPos)
                  Else
                        getFileName = ""
                  End If
            End Function
            
            Public Function getFilePath(name)
                  If dict.Exists(name) Then
                        Dim temp, tempPos
                              temp = dict(name).Item("FileName")
                              tempPos = InStrRev(temp, "\")
                              getFilePath = Mid(temp, 1, tempPos)
                  Else
                        getFilePath = ""
                  End If
            End Function
            
            Public Function getFilePathComplete(name)
                  If dict.Exists(name) Then
                        getFilePathComplete = dict(name).Item("FileName")
                  Else
                        getFilePathComplete = ""
                  End If
            End Function

            Public Function getFileSize(name)
                  If dict.Exists(name) Then
                        getFileSize = LenB(dict(name).Item("Value"))
                  Else
                        getFileSize = 0
                  End If
            End Function

            Public Function getFileSizeTranslated(name)
                  If dict.Exists(name) Then
                        temp = 1 + LenB(dict(name).Item("Value"))
                              If Len(temp) <= 3 Then
                                    getFileSizeTranslated = temp & " bytes"
                              ElseIf Len(temp) > 6 Then
                                    temp = FormatNumber(((temp / 1024) / 1024), 2)
                                    getFileSizeTranslated = temp & " megabytes"      
                              Else
                                    temp = FormatNumber((temp / 1024), 2)
                                    getFileSizeTranslated = temp & " kilobytes"
                              End If
                  Else
                        getFileSizeTranslated = ""
                  End If
            End Function
            
            Public Function getContentType(name)
                  If dict.Exists(name) Then
                        getContentType = dict(name).Item("ContentType")
                  Else
                        getContentType = ""
                  End If
            End Function

      Private Sub getData(rawData)
            Dim separator
                  separator = MidB(rawData, 1, InstrB(1, rawData, ChrB(13)) - 1)

            Dim lenSeparator
                  lenSeparator = LenB(separator)

            Dim currentPos
                  currentPos = 1
            Dim inStrByte
                  inStrByte = 1
            Dim value, mValue
            Dim tempValue
                  tempValue = ""

            While inStrByte > 0
                  inStrByte = InStrB(currentPos, rawData, separator)
                  mValue = inStrByte - currentPos

                  If mValue > 1 Then
                        value = MidB(rawData, currentPos, mValue)

                        Dim begPos, endPos, midValue, nValue
                        Dim intDict
                              Set intDict = Server.CreateObject("Scripting.Dictionary")
            
                              begPos = 1 + InStrB(1, value, ChrB(34))
                              endPos = InStrB(begPos + 1, value, ChrB(34))
                              nValue = endPos

                        Dim nameN
                              nameN = MidB(value, begPos, endPos - begPos)

                        Dim nameValue, isValid
                              isValid = True
                              
                              If InStrB(1, value, stringToByte("Content-Type")) > 1 Then

                                    begPos = 1 + InStrB(endPos + 1, value, ChrB(34))
                                    endPos = InStrB(begPos + 1, value, ChrB(34))
      
                                    If endPos = 0 Then
                                          endPos = begPos + 1
                                          isValid = False
                                    End If
                                    
                                    midValue = MidB(value, begPos, endPos - begPos)
                                          intDict.Add "FileName", trim(byteToString(midValue))
                                                
                                    begPos = 14 + InStrB(endPos + 1, value, stringToByte("Content-Type:"))
                                    endPos = InStrB(begPos, value, ChrB(13))
                                    
                                    midValue = MidB(value, begPos, endPos - begPos)
                                          intDict.Add "ContentType", trim(byteToString(midValue))
                                    
                                    begPos = endPos + 4
                                    endPos = LenB(value)

                                    nameValue = MidB(value, begPos, ((endPos - begPos) - 1))
                              Else
                                    nameValue = trim(byteToString(MidB(value, nValue + 5)))
                              End If

                              If isValid = True Then

                                    intDict.Add "Value", nameValue
                                    intDict.Add "Name", nameN

                                    dict.Add byteToString(nameN), intDict
                              End If
                  End If

                  currentPos = lenSeparator + inStrByte
            Wend
      End Sub
      
      End Class

      Private Function stringToByte(toConv)
            Dim tempChar
             For i = 1 to Len(toConv)
                   tempChar = Mid(toConv, i, 1)
                  stringToByte = stringToByte & chrB(AscB(tempChar))
             Next
      End Function

      Private Function byteToString(toConv)
            For i = 1 to LenB(toConv)
                  byteToString = byteToString & chr(AscB(MidB(toConv,i,1)))
            Next
      End Function
%>

----X----X----

Avatar of vsshah

ASKER

Now, what I am doing now. My modified code is as below.

Picture_Upload.asp

<%@LANGUAGE="VBSCRIPT"%>
<!-- #include file="UploadFile.asp" -->
<!-- #include file="../Connections/UGN_DB.asp" -->
<script language = "JavaScript">

function isDigit(theDigit)
{
var digitArray = new Array('0','1','2','3','4','5','6','7','8','9'),j;

for (j = 0; j < digitArray.length; j++)
{if (theDigit == digitArray[j])
return true
}
return false

}
/*************************************************************************/
/*Function name :isPositiveInteger(theString) */
/*Usage of this function :test for an +ve integer */
/*Input parameter required:thedata=string for test whether is +ve integer*/
/*Return value :if is +ve integer,return true */
/* else return false */
/*function require :isDigit */
/*************************************************************************/
function isPositiveInteger(theString)
{
var theData = new String(theString)

if (!isDigit(theData.charAt(0)))
if (!(theData.charAt(0)== '+'))
return false

for (var i = 1; i < theData.length; i++)
if (!isDigit(theData.charAt(i)))
return false
return true
}
/**********************************************************************/
/*Function name :isDate(s,f) */
/*Usage of this function :To check s is a valid format */
/*Input parameter required:s=input string */
/* f=input string format */
/* =1,in mm/dd/yyyy format */
/* else in dd/mm/yyyy */
/*Return value :if is a valid date return 1 */
/* else return 0 */
/*Function required :isPositiveInteger() */
/**********************************************************************/
function isDate(s,f)
{
      var a1=s.split("/");
      var a2=s.split("-");
      var e=true;
      if ((a1.length!=3) && (a2.length!=3))
      {
            e=false;
      }
      else
            {if (a1.length==3)
            var na=a1;
            if (a2.length==3)
            var na=a2;
            if (isPositiveInteger(na[0]) && isPositiveInteger(na[1]) && isPositiveInteger(na[2]))
            { if (f==1)
            {var d=na[1],m=na[0];
            }
            else
            {var d=na[0],m=na[1];
            }
            var y=na[2];
            if (((e) && (y<1000)||y.length>4))
                  e=false
                  if (e)
                  {
v=new Date(m+"/"+d+"/"+y);
if (v.getMonth()!=m-1)
e=false;
}
}
else
{
e=false;
}
}
return e
}

function CheckDate(v)
{
      var s=v.value;

      if (!(s == ""))      
      {
            if (!(isDate(s,1))) //dd/mm/yyyy format
            {      
                  alert("The inputed date value is not valid. Please Enter date in mm/dd/yyyy format");
                  document.form1.CartName.focus();      
                  v.value = "";
                  v.focus();
                  return false;                   
            }
      }      
      
}

function CheckGrossWeight(v)
{
      var s=v.value;

            if (isNaN(s))
            {
                  alert("Please enter Gross Weight using numeric characters only! Your entered value '" + s + "' is not numeric.");
                  document.form1.CartName.focus();      
                  v.value = "";                   
                  v.focus();
                  return false;
            }
}

function CheckQtyPacked(v)
{
      var s=v.value;

            if (isNaN(s))
            {
                  alert("Please enter Qty Packed using numeric characters only! Your entered value '" + s + "' is not numeric.");
                  //document.form2.qtypacked.focus();      
                  v.value = "";                   
                  v.focus();
                  return false;
            }
}

function deletebuttonclick(msg)
{
      //confirm(msg);
      var x=window.confirm(msg)
      if (x)
      {
            location.href = "Cart_Delete.asp?" + document.form1.MM_QueryString.value;
            return true;
      }
      else
      {
            //alert("Not Agree");  
      }
}

function uploadbuttonclick(uploadedfile)
{
      alert("uploadedfile = " + uploadedfile.value );
      newWindow = window.open();
      newWindow.location.href = "Picture_Upload_Action.asp?" + "<%=Request.QueryString%>" + "&uploadedfile=" + uploadedfile.value;

}

function previewbuttonclick()
{
      newWindow = window.open();
      newWindow.location.href = "rpt_packaging_layout.asp?CartName=" + document.form1.CartName.value + "&CustId=" + document.form1.CustId.value + "&CustPlant=" + document.form1.CustPlant.value;
}

function checkfiletype(thevalue)
{
  var regx = new RegExp(".jpg$","i")
  var regx2 = new RegExp(".bmp$","i")

  if (regx.test(thevalue))
  {
      return true;      
  }
  else if (regx2.test(thevalue))
  {
      return true;      
  }
  else
  {
    alert("Please Select only .jpg or .bmp fles")
      document.form2.Submit2.focus;
      document.form2.attach1.value = "";
      thevalue.focus;
      return false;
  }
}

function filetypecheck()
{
  var regx = new RegExp(".jpg$","i")
  var regx2 = new RegExp(".bmp$","i")

  //if (regx.test(document.form2.file.value))
  if (regx.test(document.form2.attach1.value))
  {
      return true;      
  }
  else if (regx2.test(document.form2.attach1.value))
  {
      return true;      
  }
  else
  {
    alert("Please Select only .jpg or .bmp fles")
      return false;
  }

}

function checkfields()
{
      var num = document.form1.elements.length

      var localpcks002 = "<%=session("PCKS002")%>"; //NEW CONTAINER Entry
      var ugnDeptNo        = "<%=session("MM_UGNDeptNo")%>"; // Dept # 6 - Packaging
      var ugnUserId        = "<%=session("MM_UserId")%>"; //EmpId of User

      //alert("localpcks001 = " + localpcks001 + ", ugnDeptNo = " + ugnDeptNo + ", ugnUserId = " + ugnUserId );

      for (var i=0; i<num;i++)
      {

            if ( localpcks002 == "E" )       //Packaging Dept user will have EDIT rights
            {
                  document.form1.elements[i].disabled = false;            
            }
            else //// Select/ReadOnly. None of above condition satisfied then disable all fields.
            {
                  document.form1.elements[i].disabled = true;            
            }

      }      
      
} // end of function checkfields()

function checkfieldsform2()
{
      var num = document.form2.elements.length

      var localpcks002 = "<%=session("PCKS002")%>"; //NEW CONTAINER Entry
      var ugnDeptNo        = "<%=session("MM_UGNDeptNo")%>"; // Dept # 6 - Packaging
      var ugnUserId        = "<%=session("MM_UserId")%>"; //EmpId of User

      //alert("localpcks001 = " + localpcks001 + ", ugnDeptNo = " + ugnDeptNo + ", ugnUserId = " + ugnUserId );

      for (var i=0; i<num;i++)
      {

            if ( localpcks002 == "E" )       //Packaging Dept user will have EDIT rights
            {
                  document.form2.elements[i].disabled = false;            
            }
            else //// Select/ReadOnly. None of above condition satisfied then disable all fields.
            {
                  document.form2.elements[i].disabled = true;            
            }

      }      
      
} // end of function checkfieldsform2()



</script>

<%
' *** Logout the current user.
MM_Logout = CStr(Request.ServerVariables("URL")) & "?MM_Logoutnow=1"
If (CStr(Request("MM_Logoutnow")) = "1") Then
  Session.Contents.Remove("MM_Username")
  Session.Contents.Remove("MM_UserAuthorization")
  MM_logoutRedirectPage = "../ugndb_login.asp"
  ' redirect with URL parameters (remove the "MM_Logoutnow" query param).
  if (MM_logoutRedirectPage = "") Then MM_logoutRedirectPage = CStr(Request.ServerVariables("URL"))
  If (InStr(1, UC_redirectPage, "?", vbTextCompare) = 0 And Request.QueryString <> "") Then
    MM_newQS = "?"
    For Each Item In Request.QueryString
      If (Item <> "MM_Logoutnow") Then
        If (Len(MM_newQS) > 1) Then MM_newQS = MM_newQS & "&"
        MM_newQS = MM_newQS & Item & "=" & Server.URLencode(Request.QueryString(Item))
      End If
    Next
    if (Len(MM_newQS) > 1) Then MM_logoutRedirectPage = MM_logoutRedirectPage & MM_newQS
  End If
  Response.Redirect(MM_logoutRedirectPage)
End If
%>

<%
' *** Edit Operations: declare variables

Dim MM_editAction
Dim MM_abortEdit
Dim MM_editQuery
Dim MM_editCmd

Dim MM_editConnection
Dim MM_editTable
Dim MM_editRedirectUrl
Dim MM_editColumn
Dim MM_recordId

Dim MM_fieldsStr
Dim MM_columnsStr
Dim MM_fields
Dim MM_columns
Dim MM_typeArray
Dim MM_formVal
Dim MM_delim
Dim MM_altVal
Dim MM_emptyVal
Dim MM_i

MM_editAction = CStr(Request.ServerVariables("SCRIPT_NAME"))
If (Request.QueryString <> "") Then
  MM_editAction = MM_editAction & "?" & Server.HTMLEncode(Request.QueryString)
End If

' boolean to abort record edit
MM_abortEdit = false

' query string to execute
MM_editQuery = ""
%>
<%
' *** Update Record: set variables

If (CStr(Request("MM_update")) = "form1" And CStr(Request("MM_recordId")) <> "") Then

  MM_editConnection = MM_UGN_DB_STRING
  MM_editTable = "dbo.Cart_M"
  MM_editColumn = "CartName"
  MM_recordId = "'" + Request.Form("MM_recordId") + "'"
  MM_editRedirectUrl = "Picture_Upload.asp"
  MM_fieldsStr  = "CartName|value|ContainerNo|value|CustId|value|CustPlant|value|modelyear|value|Model|value|UGNFacility|value|UGNDeptNo|value|RevisionDate|value|EmpId|value|SingleMultiPartFlag|value|GrossWeight|value|IsPublished|value"
  MM_columnsStr = "CartName|',none,''|ContainerNo|',none,''|CustId|none,none,NULL|CustPlant|',none,''|ModelYear|none,none,NULL|Model|',none,''|UGNFacility|none,none,NULL|UGNDeptNo|none,none,NULL|RevisionDate|',none,NULL|EmpId|none,none,NULL|SingleMultiPartFlag|',none,''|GrossWeight|none,none,NULL|IsPublished|none,none,NULL"

  ' create the MM_fields and MM_columns arrays
  MM_fields = Split(MM_fieldsStr, "|")
  MM_columns = Split(MM_columnsStr, "|")
 
  ' set the form values
  For MM_i = LBound(MM_fields) To UBound(MM_fields) Step 2
    MM_fields(MM_i+1) = CStr(Request.Form(MM_fields(MM_i)))
  Next

  ' append the query string to the redirect URL
  If (MM_editRedirectUrl <> "" And Request.QueryString <> "") Then
    If (InStr(1, MM_editRedirectUrl, "?", vbTextCompare) = 0 And Request.QueryString <> "") Then
      MM_editRedirectUrl = MM_editRedirectUrl & "?" & Request.QueryString
    Else
      MM_editRedirectUrl = MM_editRedirectUrl & "&" & Request.QueryString
    End If
  End If

End If
%>
<%
' *** Update Record: construct a sql update statement and execute it

If (CStr(Request("MM_update")) <> "" And CStr(Request("MM_recordId")) <> "") Then

  ' create the sql update statement
  MM_editQuery = "update " & MM_editTable & " set "
  For MM_i = LBound(MM_fields) To UBound(MM_fields) Step 2
    MM_formVal = MM_fields(MM_i+1)
    MM_typeArray = Split(MM_columns(MM_i+1),",")
    MM_delim = MM_typeArray(0)
    If (MM_delim = "none") Then MM_delim = ""
    MM_altVal = MM_typeArray(1)
    If (MM_altVal = "none") Then MM_altVal = ""
    MM_emptyVal = MM_typeArray(2)
    If (MM_emptyVal = "none") Then MM_emptyVal = ""
    If (MM_formVal = "") Then
      MM_formVal = MM_emptyVal
    Else
      If (MM_altVal <> "") Then
        MM_formVal = MM_altVal
      ElseIf (MM_delim = "'") Then  ' escape quotes
        MM_formVal = "'" & Replace(MM_formVal,"'","''") & "'"
      Else
        MM_formVal = MM_delim + MM_formVal + MM_delim
      End If
    End If
    If (MM_i <> LBound(MM_fields)) Then
      MM_editQuery = MM_editQuery & ","
    End If
    MM_editQuery = MM_editQuery & MM_columns(MM_i) & " = " & MM_formVal
  Next
  MM_editQuery = MM_editQuery & " where " & MM_editColumn & " = " & MM_recordId

  If (Not MM_abortEdit) Then
    ' execute the update
    Set MM_editCmd = Server.CreateObject("ADODB.Command")
    MM_editCmd.ActiveConnection = MM_editConnection
    MM_editCmd.CommandText = MM_editQuery
    MM_editCmd.Execute
    MM_editCmd.ActiveConnection.Close

    If (MM_editRedirectUrl <> "") Then
      Response.Redirect(MM_editRedirectUrl)
    End If
  End If

End If
%>
<%
Dim Cart_M__vCartName
Cart_M__vCartName = "%"
If (Request.QueryString("CartName")  <> "") Then
  Cart_M__vCartName = Request.QueryString("CartName")
End If
%>
<%
Dim Cart_M__vCustId
Cart_M__vCustId = "0"
If (Request.QueryString("CustId")  <> "") Then
  Cart_M__vCustId = Request.QueryString("CustId")
End If
%>
<%
Dim Cart_M__VCustPlant
Cart_M__VCustPlant = "%"
If (Request.QueryString("CustPlant")   <> "") Then
  Cart_M__VCustPlant = Request.QueryString("CustPlant")  
End If
%>
<%
Dim Cart_M
Dim Cart_M_numRows

Set Cart_M = Server.CreateObject("ADODB.Recordset")
Cart_M.ActiveConnection = MM_UGN_DB_STRING
Cart_M.Source = "SELECT CartName, ContainerNo, RevisionDate, CustId, CustPlant, Model, ModelYear, EmpId, GrossWeight, IsPublished, UGNFacility, UGNDeptNo, SingleMultiPartFlag  FROM Cart_M  WHERE Cart_M.CartName = '" + Replace(Cart_M__vCartName, "'", "''") + "' and Cart_M.CustId = '" + Replace(Cart_M__vCustId, "'", "''") + "' and Cart_M.CustPlant = '" + Replace(Cart_M__VCustPlant, "'", "''") + "'  ORDER BY Cart_M.CartName"      
'response.write("Cart_M.Source = " & Cart_M.Source)
'response.end
Cart_M.CursorType = 0
Cart_M.CursorLocation = 2
Cart_M.LockType = 1
Cart_M.Open()

Cart_M_numRows = 0
%>
<%
Dim Cust_M
Dim Cust_M_numRows

Set Cust_M = Server.CreateObject("ADODB.Recordset")
Cust_M.ActiveConnection = MM_UGN_DB_STRING
Cust_M.Source = "SELECT Cust_M.CustId, Cust_M.CustName FROM Cust_M ORDER BY CustName "
Cust_M.CursorType = 0
Cust_M.CursorLocation = 2
Cust_M.LockType = 1
Cust_M.Open()

Cust_M_numRows = 0
%>
<%
Dim Cust_Plant_M
Dim Cust_Plant_M_numRows

Set Cust_Plant_M = Server.CreateObject("ADODB.Recordset")
Cust_Plant_M.ActiveConnection = MM_UGN_DB_STRING
Cust_Plant_M.Source = "SELECT Cust_Plant_M.CustPlant, Cust_M.CustName + '-> ' + Cust_Plant_M.CustPlant as CustPlantName FROM Cust_M, Cust_Plant_M Where Cust_M.CustId = Cust_Plant_M.CustId ORDER BY Cust_M.CustName, Cust_Plant_M.CustPlant  "
Cust_Plant_M.CursorType = 0
Cust_Plant_M.CursorLocation = 2
Cust_Plant_M.LockType = 1
Cust_Plant_M.Open()

Cust_Plant_M_numRows = 0
%>
<%
Dim Employee_M
Dim Employee_M_numRows

Set Employee_M = Server.CreateObject("ADODB.Recordset")
Employee_M.ActiveConnection = MM_UGN_DB_STRING
Employee_M.Source = "SELECT EmpId, EmplastName + ', ' + EmpFirstName AS EmpName  FROM Employee_M  WHERE EmpStatus='Working'  ORDER BY EmplastName +' '+ EmpFirstName"
Employee_M.CursorType = 0
Employee_M.CursorLocation = 2
Employee_M.LockType = 1
Employee_M.Open()

Employee_M_numRows = 0
%>
<%
Dim Container_M
Dim Container_M_numRows

Set Container_M = Server.CreateObject("ADODB.Recordset")
Container_M.ActiveConnection = MM_UGN_DB_STRING
Container_M.Source = "SELECT Container_M.ContainerNo  FROM Container_M  ORDER BY Container_M.ContainerNo"
Container_M.CursorType = 0
Container_M.CursorLocation = 2
Container_M.LockType = 1
Container_M.Open()

Container_M_numRows = 0
%>
<%
Dim UGN_Facility_M
Dim UGN_Facility_M_numRows

Set UGN_Facility_M = Server.CreateObject("ADODB.Recordset")
UGN_Facility_M.ActiveConnection = MM_UGN_DB_STRING
UGN_Facility_M.Source = "Select UGNFacility, UGNFacilityName from UGN_Facility_M Where UGNFacility < 15 Order By UGNFacility"
UGN_Facility_M.CursorType = 0
UGN_Facility_M.CursorLocation = 2
UGN_Facility_M.LockType = 1
UGN_Facility_M.Open()

UGN_Facility_M_numRows = 0
%>
<%
Dim UGN_Dept_M
Dim UGN_Dept_M_numRows

Set UGN_Dept_M = Server.CreateObject("ADODB.Recordset")
UGN_Dept_M.ActiveConnection = MM_UGN_DB_STRING
UGN_Dept_M.Source = "Select UGNDeptNo, UGNDeptName from UGN_Dept_M Where UGNDeptNo > 0 Order By UGNDeptName"
UGN_Dept_M.CursorType = 0
UGN_Dept_M.CursorLocation = 2
UGN_Dept_M.LockType = 1
UGN_Dept_M.Open()

UGN_Dept_M_numRows = 0
%>
<html><!-- InstanceBegin template="file:///C|/Inetpub/wwwroot/Main Menu/Templates/temp_red.dwt" codeOutsideHTMLIsLocked="false" -->
<head>
<!-- InstanceBeginEditable name="doctitle" -->
<title>Picture Upload</title>
<!-- InstanceEndEditable -->
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<!-- InstanceBeginEditable name="head" -->
<script language="JavaScript" type="text/JavaScript">
<!--
function MM_goToURL() { //v3.0
  var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}
//-->
</script>
<!-- InstanceEndEditable -->
<script language="JavaScript">
<!--
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
//-->
<!--
function TJK_noWayBack(){// http://www.MadCoWWWebDesign.com - Thierry Koblentz
 history.go(1);
}
TJK_noWayBack();
//-->
</script>
</head>
<body bgcolor="#FFFFFF" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" onLoad="TJK_noWayBack()">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td rowspan="2" bgcolor="#666666"> <img src="http://ugndb/onTrack/images/luxury.png" name="image" width="125" height="50">
    </td>
    <td width="100%" bgcolor="#CCCCCC"><font color="#de192b" size="1" face="Verdana, Arial, Helvetica, sans-serif">
      <strong>UGN, Inc.</strong></font></td>
  </tr>
  <tr>
    <td align="left" valign="bottom" bgcolor="#CCCCCC"><strong><font size="-1">Your
          logged in as <font color="#de192b" size="1" face="Verdana, Arial, Helvetica, sans-serif">
      <strong><%=Session("MM_UserName")%></strong></font> .</font></strong></td>
  </tr>
</table>
<!-- InstanceBeginEditable name="Body" -->
<table width="100%" border="0" cellspacing="2" cellpadding="4" align="center">
  <tr bgcolor="#333333">
    <td width="12%"><table width="100%" border="0" cellspacing="0" cellpadding="4">
        <tr>
          <td nowrap bgcolor="#de192b"><font color="#CCCCCC" size="1"><b>Quick
                Links</b></font></td>
        </tr>
      </table>
    </td>
    <td width="88%">
      <table width="100%" border="0" cellspacing="0" cellpadding="4">
        <tr>
          <td bgcolor="#de192b">&nbsp;&nbsp;</td>
          <td width="100%"> <font color="#CCCCCC"> <b>Create/Modify Packaging
                Layout</b></font></td>
        </tr>
      </table>
    </td>
  </tr>
</table>
<table width="123%" border="0" cellspacing="4" cellpadding="4" align="center">
  <tr>
    <td width="12%" valign="top">
    <table>
      <tr>
        <td height="21"><a href="Packaging_Module_Menu.asp"><img src="../images/pkgm.gif" width="108" height="19" border="0"></a></td>
      </tr>
      <tr>
        <td>&nbsp;</td>
      </tr>
      <tr>
        <td>&nbsp;</td>
      </tr>
      <tr>
        <td><hr>
        </td>
      </tr>
      <tr>
        <td><strong><a href="http://ugndb/ugnmainmenu/Main_Menu.asp?<%="UgnFacility=" &  Session("MM_EmpUGNfacility") %>"><img src="../images/bugn.gif" width="108" height="29" border="0"></a></strong></td>
      </tr>
      <tr>
        <td><strong><font size="-1"><a href="<%= MM_Logout %>"><img src="../images/bso.gif" width="108" height="18" border="0"></a></font></strong></td>
      </tr>
    </table>
    <p><strong></strong></p>      <strong></strong><strong></strong><strong></strong><strong></strong><strong><font color="#000000">&nbsp;</font></strong></td>
    <td width="88%" valign="top"> <table width="79%" border="0">
      <tr>
        <td bordercolor="#FFFFFF">
          <form METHOD="POST" name="form1" action="<%=MM_editAction%>">
            <table width="715" border="0">
              <tr>
                <td width="124"><div align="right"><strong><font size="-1"><font color="#990000">*</font>Part Number :</font></strong></div></td>
                <td width="182"><input name="CartName" type="text" id="CartName" value="<%=(Cart_M.Fields.Item("CartName").Value)%>"></td>
                <td width="103"><div align="right"><strong><font size="-1">Container No: </font></strong></div></td>
                <td width="212"><select name="ContainerNo" id="ContainerNo">
                  <option value="" <%If (Not isNull((Cart_M.Fields.Item("ContainerNo").Value))) Then If ("" = CStr((Cart_M.Fields.Item("ContainerNo").Value))) Then Response.Write("SELECTED") : Response.Write("")%>></option>
                  <%
While (NOT Container_M.EOF)
%>
                  <option value="<%=(Container_M.Fields.Item("ContainerNo").Value)%>" <%If (Not isNull((Cart_M.Fields.Item("ContainerNo").Value))) Then If (CStr(Container_M.Fields.Item("ContainerNo").Value) = CStr((Cart_M.Fields.Item("ContainerNo").Value))) Then Response.Write("SELECTED") : Response.Write("")%> ><%=(Container_M.Fields.Item("ContainerNo").Value)%></option>
                    <%
  Container_M.MoveNext()
Wend
If (Container_M.CursorType > 0) Then
  Container_M.MoveFirst
Else
  Container_M.Requery
End If
%>
                </select></td>
              </tr>
              <tr>
                <td><div align="right"><strong><font size="-1"><font color="#990000">*</font>Customer: </font></strong></div></td>
                <td><select name="CustId" id="CustId" onchange="custplantrefresh()">
                  <option value="" <%If (Not isNull((Cart_M.Fields.Item("CustId").Value))) Then If ("" = CStr((Cart_M.Fields.Item("CustId").Value))) Then Response.Write("SELECTED") : Response.Write("")%>></option>
                  <%
While (NOT Cust_M.EOF)
%>
                  <option value="<%=(Cust_M.Fields.Item("CustId").Value)%>" <%If (Not isNull((Cart_M.Fields.Item("CustId").Value))) Then If (CStr(Cust_M.Fields.Item("CustId").Value) = CStr((Cart_M.Fields.Item("CustId").Value))) Then Response.Write("SELECTED") : Response.Write("")%> ><%=(Cust_M.Fields.Item("CustName").Value)%></option>
                    <%
  Cust_M.MoveNext()
Wend
If (Cust_M.CursorType > 0) Then
  Cust_M.MoveFirst
Else
  Cust_M.Requery
End If
%>
                </select></td>
                <td><div align="right"><strong><font size="-1"><font color="#990000">*</font>Customer Plant:</font></strong></div></td>
                <td><select name="CustPlant" id="CustPlant">
                  <option value="" <%If (Not isNull((Cart_M.Fields.Item("CustPlant").Value))) Then If ("" = CStr((Cart_M.Fields.Item("CustPlant").Value))) Then Response.Write("SELECTED") : Response.Write("")%>></option>
                  <%
While (NOT Cust_Plant_M.EOF)
%>
                  <option value="<%=(Cust_Plant_M.Fields.Item("CustPlant").Value)%>" <%If (Not isNull((Cart_M.Fields.Item("CustPlant").Value))) Then If (CStr(Cust_Plant_M.Fields.Item("CustPlant").Value) = CStr((Cart_M.Fields.Item("CustPlant").Value))) Then Response.Write("SELECTED") : Response.Write("")%> ><%=(Cust_Plant_M.Fields.Item("CustPlantName").Value)%></option>
                    <%
  Cust_Plant_M.MoveNext()
Wend
If (Cust_Plant_M.CursorType > 0) Then
  Cust_Plant_M.MoveFirst
Else
  Cust_Plant_M.Requery
End If
%>
                </select></td>
              </tr>
              <tr>
                <td><div align="right"><strong><font size="-1">Model Year:</font></strong></div></td>
                <td><select name="modelyear">
                  <option value=""  <%If (Not isNull((Cart_M.Fields.Item("ModelYear").Value))) Then If ("" = CStr((Cart_M.Fields.Item("ModelYear").Value))) Then Response.Write("SELECTED") : Response.Write("")%>></option>
                  <option value="1991"  <%If (Not isNull((Cart_M.Fields.Item("ModelYear").Value))) Then If ("1991" = CStr((Cart_M.Fields.Item("ModelYear").Value))) Then Response.Write("SELECTED") : Response.Write("")%>>1991</option>
                    <option value="1992"  <%If (Not isNull((Cart_M.Fields.Item("ModelYear").Value))) Then If ("1992" = CStr((Cart_M.Fields.Item("ModelYear").Value))) Then Response.Write("SELECTED") : Response.Write("")%>>1992</option>
                    <option value="1993"  <%If (Not isNull((Cart_M.Fields.Item("ModelYear").Value))) Then If ("1993" = CStr((Cart_M.Fields.Item("ModelYear").Value))) Then Response.Write("SELECTED") : Response.Write("")%>>1993</option>
                    <option value="1994"  <%If (Not isNull((Cart_M.Fields.Item("ModelYear").Value))) Then If ("1994" = CStr((Cart_M.Fields.Item("ModelYear").Value))) Then Response.Write("SELECTED") : Response.Write("")%>>1994</option>
                    <option value="1995"  <%If (Not isNull((Cart_M.Fields.Item("ModelYear").Value))) Then If ("1995" = CStr((Cart_M.Fields.Item("ModelYear").Value))) Then Response.Write("SELECTED") : Response.Write("")%>>1995</option>
                    <option value="1996"  <%If (Not isNull((Cart_M.Fields.Item("ModelYear").Value))) Then If ("1996" = CStr((Cart_M.Fields.Item("ModelYear").Value))) Then Response.Write("SELECTED") : Response.Write("")%>>1996</option>
                    <option value="1997"  <%If (Not isNull((Cart_M.Fields.Item("ModelYear").Value))) Then If ("1997" = CStr((Cart_M.Fields.Item("ModelYear").Value))) Then Response.Write("SELECTED") : Response.Write("")%>>1997</option>
                    <option value="1998"  <%If (Not isNull((Cart_M.Fields.Item("ModelYear").Value))) Then If ("1998" = CStr((Cart_M.Fields.Item("ModelYear").Value))) Then Response.Write("SELECTED") : Response.Write("")%>>1998</option>
                    <option value="1999"  <%If (Not isNull((Cart_M.Fields.Item("ModelYear").Value))) Then If ("1999" = CStr((Cart_M.Fields.Item("ModelYear").Value))) Then Response.Write("SELECTED") : Response.Write("")%>>1999</option>
                    <option value="2000"  <%If (Not isNull((Cart_M.Fields.Item("ModelYear").Value))) Then If ("2000" = CStr((Cart_M.Fields.Item("ModelYear").Value))) Then Response.Write("SELECTED") : Response.Write("")%>>2000</option>
                    <option value="2001"  <%If (Not isNull((Cart_M.Fields.Item("ModelYear").Value))) Then If ("2001" = CStr((Cart_M.Fields.Item("ModelYear").Value))) Then Response.Write("SELECTED") : Response.Write("")%>>2001</option>
                    <option value="2002"  <%If (Not isNull((Cart_M.Fields.Item("ModelYear").Value))) Then If ("2002" = CStr((Cart_M.Fields.Item("ModelYear").Value))) Then Response.Write("SELECTED") : Response.Write("")%>>2002</option>
                    <option value="2003"  <%If (Not isNull((Cart_M.Fields.Item("ModelYear").Value))) Then If ("2003" = CStr((Cart_M.Fields.Item("ModelYear").Value))) Then Response.Write("SELECTED") : Response.Write("")%>>2003</option>
                    <option value="2004"  <%If (Not isNull((Cart_M.Fields.Item("ModelYear").Value))) Then If ("2004" = CStr((Cart_M.Fields.Item("ModelYear").Value))) Then Response.Write("SELECTED") : Response.Write("")%>>2004</option>
                    <option value="2005"  <%If (Not isNull((Cart_M.Fields.Item("ModelYear").Value))) Then If ("2005" = CStr((Cart_M.Fields.Item("ModelYear").Value))) Then Response.Write("SELECTED") : Response.Write("")%>>2005</option>
                    <option value="2006"  <%If (Not isNull((Cart_M.Fields.Item("ModelYear").Value))) Then If ("2006" = CStr((Cart_M.Fields.Item("ModelYear").Value))) Then Response.Write("SELECTED") : Response.Write("")%>>2006</option>
                    <option value="2007"  <%If (Not isNull((Cart_M.Fields.Item("ModelYear").Value))) Then If ("2007" = CStr((Cart_M.Fields.Item("ModelYear").Value))) Then Response.Write("SELECTED") : Response.Write("")%>>2007</option>
                    <option value="2008"  <%If (Not isNull((Cart_M.Fields.Item("ModelYear").Value))) Then If ("2008" = CStr((Cart_M.Fields.Item("ModelYear").Value))) Then Response.Write("SELECTED") : Response.Write("")%>>2008</option>
                    <option value="2009"  <%If (Not isNull((Cart_M.Fields.Item("ModelYear").Value))) Then If ("2009" = CStr((Cart_M.Fields.Item("ModelYear").Value))) Then Response.Write("SELECTED") : Response.Write("")%>>2009</option>
                    <option value="2010"  <%If (Not isNull((Cart_M.Fields.Item("ModelYear").Value))) Then If ("2010" = CStr((Cart_M.Fields.Item("ModelYear").Value))) Then Response.Write("SELECTED") : Response.Write("")%>>2010</option>
                    <option value="2011"  <%If (Not isNull((Cart_M.Fields.Item("ModelYear").Value))) Then If ("2011" = CStr((Cart_M.Fields.Item("ModelYear").Value))) Then Response.Write("SELECTED") : Response.Write("")%>>2011</option>
                    <option value="2012"  <%If (Not isNull((Cart_M.Fields.Item("ModelYear").Value))) Then If ("2012" = CStr((Cart_M.Fields.Item("ModelYear").Value))) Then Response.Write("SELECTED") : Response.Write("")%>>2012</option>
                    <option value="2013"  <%If (Not isNull((Cart_M.Fields.Item("ModelYear").Value))) Then If ("2013" = CStr((Cart_M.Fields.Item("ModelYear").Value))) Then Response.Write("SELECTED") : Response.Write("")%>>2013</option>
                    <option value="2014"  <%If (Not isNull((Cart_M.Fields.Item("ModelYear").Value))) Then If ("2014" = CStr((Cart_M.Fields.Item("ModelYear").Value))) Then Response.Write("SELECTED") : Response.Write("")%>>2014</option>
                    <option value="2015"  <%If (Not isNull((Cart_M.Fields.Item("ModelYear").Value))) Then If ("2015" = CStr((Cart_M.Fields.Item("ModelYear").Value))) Then Response.Write("SELECTED") : Response.Write("")%>>2015</option>
                    <option value="2016"  <%If (Not isNull((Cart_M.Fields.Item("ModelYear").Value))) Then If ("2016" = CStr((Cart_M.Fields.Item("ModelYear").Value))) Then Response.Write("SELECTED") : Response.Write("")%>>2016</option>
                    <option value="2017"  <%If (Not isNull((Cart_M.Fields.Item("ModelYear").Value))) Then If ("2017" = CStr((Cart_M.Fields.Item("ModelYear").Value))) Then Response.Write("SELECTED") : Response.Write("")%>>2017</option>
                    <option value="2018"  <%If (Not isNull((Cart_M.Fields.Item("ModelYear").Value))) Then If ("2018" = CStr((Cart_M.Fields.Item("ModelYear").Value))) Then Response.Write("SELECTED") : Response.Write("")%>>2018</option>
                    <option value="2019"  <%If (Not isNull((Cart_M.Fields.Item("ModelYear").Value))) Then If ("2019" = CStr((Cart_M.Fields.Item("ModelYear").Value))) Then Response.Write("SELECTED") : Response.Write("")%>>2019</option>
                    <option value="2020"  <%If (Not isNull((Cart_M.Fields.Item("ModelYear").Value))) Then If ("2020" = CStr((Cart_M.Fields.Item("ModelYear").Value))) Then Response.Write("SELECTED") : Response.Write("")%>>2020</option>
                </select></td>
                <td><div align="right"><strong><font size="-1">Model:</font></strong></div></td>
                <td><input name="Model" type="text" id="Model" value="<%=(Cart_M.Fields.Item("Model").Value)%>"></td>
              </tr>
              <tr>
                <td><div align="right"><strong><font size="-1">UGN Facility:</font></strong></div></td>
                <td><select name="UGNFacility" id="UGNFacility">
                  <option value="" <%If (Not isNull((Cart_M.Fields.Item("UGNFacility").Value))) Then If ("" = CStr((Cart_M.Fields.Item("UGNFacility").Value))) Then Response.Write("SELECTED") : Response.Write("")%>></option>
                  <%
While (NOT UGN_Facility_M.EOF)
%>
                  <option value="<%=(UGN_Facility_M.Fields.Item("UGNFacility").Value)%>" <%If (Not isNull((Cart_M.Fields.Item("UGNFacility").Value))) Then If (CStr(UGN_Facility_M.Fields.Item("UGNFacility").Value) = CStr((Cart_M.Fields.Item("UGNFacility").Value))) Then Response.Write("SELECTED") : Response.Write("")%> ><%=(UGN_Facility_M.Fields.Item("UGNFacilityName").Value)%></option>
                    <%
  UGN_Facility_M.MoveNext()
Wend
If (UGN_Facility_M.CursorType > 0) Then
  UGN_Facility_M.MoveFirst
Else
  UGN_Facility_M.Requery
End If
%>
                </select></td>
                <td><div align="right"><strong><font size="-1">UGN Department: </font></strong></div></td>
                <td><select name="UGNDeptNo" id="UGNDeptNo">
                  <option value="" <%If (Not isNull((Cart_M.Fields.Item("UGNDeptNo").Value))) Then If ("" = CStr((Cart_M.Fields.Item("UGNDeptNo").Value))) Then Response.Write("SELECTED") : Response.Write("")%>></option>
                  <%
While (NOT UGN_Dept_M.EOF)
%>
                  <option value="<%=(UGN_Dept_M.Fields.Item("UGNDeptNo").Value)%>" <%If (Not isNull((Cart_M.Fields.Item("UGNDeptNo").Value))) Then If (CStr(UGN_Dept_M.Fields.Item("UGNDeptNo").Value) = CStr((Cart_M.Fields.Item("UGNDeptNo").Value))) Then Response.Write("SELECTED") : Response.Write("")%> ><%=(UGN_Dept_M.Fields.Item("UGNDeptName").Value)%></option>
                    <%
  UGN_Dept_M.MoveNext()
Wend
If (UGN_Dept_M.CursorType > 0) Then
  UGN_Dept_M.MoveFirst
Else
  UGN_Dept_M.Requery
End If
%>
                </select></td>
              </tr>
              <tr>
                <td><div align="right"><strong><font size="-1">Revision Date:</font></strong></div></td>
                <td><input name="RevisionDate" type="text" id="RevisionDate" onChange=CheckDate(this.form.RevisionDate) value="<%=(Cart_M.Fields.Item("RevisionDate").Value)%>" ></td>
                <td><div align="right"><strong><font size="-1">Employee:</font></strong></div></td>
                <td><select name="EmpId" >
                  <option value="" <%If (Not isNull((Cart_M.Fields.Item("EmpId").Value))) Then If ("" = CStr((Cart_M.Fields.Item("EmpId").Value))) Then Response.Write("SELECTED") : Response.Write("")%>></option>
                  <%
While (NOT Employee_M.EOF)
%>
                  <option value="<%=(Employee_M.Fields.Item("EmpId").Value)%>" <%If (Not isNull((Cart_M.Fields.Item("EmpId").Value))) Then If (CStr(Employee_M.Fields.Item("EmpId").Value) = CStr((Cart_M.Fields.Item("EmpId").Value))) Then Response.Write("SELECTED") : Response.Write("")%> ><%=(Employee_M.Fields.Item("EmpName").Value)%></option>
                    <%
  Employee_M.MoveNext()
Wend
If (Employee_M.CursorType > 0) Then
  Employee_M.MoveFirst
Else
  Employee_M.Requery
End If
%>
                </select></td>
              </tr>
              <tr>
                <td><div align="right"><strong><font size="-1">Single/Multiple Part :</font></strong></div></td>
                <td><select name="SingleMultiPartFlag" id="SingleMultiPartFlag">
                  <option value="" <%If (Not isNull((Cart_M.Fields.Item("SingleMultiPartFlag").Value))) Then If ("" = CStr((Cart_M.Fields.Item("SingleMultiPartFlag").Value))) Then Response.Write("SELECTED") : Response.Write("")%>></option>
                  <option value="S" <%If (Not isNull((Cart_M.Fields.Item("SingleMultiPartFlag").Value))) Then If ("S" = CStr((Cart_M.Fields.Item("SingleMultiPartFlag").Value))) Then Response.Write("SELECTED") : Response.Write("")%>>Single</option>
                    <option value="M" <%If (Not isNull((Cart_M.Fields.Item("SingleMultiPartFlag").Value))) Then If ("M" = CStr((Cart_M.Fields.Item("SingleMultiPartFlag").Value))) Then Response.Write("SELECTED") : Response.Write("")%>>Multiple</option>
                </select></td>
                <td><div align="right"><strong><font size="-1">Gross Weight: </font></strong></div></td>
                <td><input name="GrossWeight" type="text" id="GrossWeight" onBlur="CheckGrossWeight(this.form.GrossWeight)" value="<%=(Cart_M.Fields.Item("GrossWeight").Value)%>" maxlength="6"></td>
              </tr>
              <tr>
                <td><div align="right"><strong><font size="-1">Is Published:</font></strong></div></td>
                <td><select name="IsPublished" id="IsPublished">
                  <option value="0" <%If (Not isNull((Cart_M.Fields.Item("IsPublished").Value))) Then If ("0" = CStr((Cart_M.Fields.Item("IsPublished").Value))) Then Response.Write("SELECTED") : Response.Write("")%>>No</option>
                  <option value="1" selected  <%If (Not isNull((Cart_M.Fields.Item("IsPublished").Value))) Then If ("1" = CStr((Cart_M.Fields.Item("IsPublished").Value))) Then Response.Write("SELECTED") : Response.Write("")%>>Yes</option>
                </select></td>
                <td>&nbsp;</td>
                <td><div align="right">
                  <input name="previewbutton" type="button" id="previewbutton" value="Preview" onclick="previewbuttonclick()">
                  <input type="submit" name="Submit" onClick="return savebuttonclick()" value="Save">
                  <input type="button" name="Button" onClick="return deletebuttonclick('Part Record to be Deleted?')" value="Delete">
                </div></td>
              </tr>
            </table>
         
            <input type="hidden" name="MM_update" value="form1">
            <input type="hidden" name="MM_recordId" value="<%= Cart_M.Fields.Item("CartName").Value %>">
            <input type="hidden" name="MM_QueryString" value="<%=Request.QueryString%>">
            <%
                        Response.Write ("<script language='JavaScript'>checkfields();</script>")      
                  %>
          </form>    
              </td>
      </tr>
      <tr>
        <td bordercolor="#FFFFFF"><img src="images/picture.png" width="598" height="27" border="0" usemap="#Map">
          <map name="Map">
          <area shape="rect" coords="15,2,95,23" href="Part_Detail_List.asp?CartName=<%=Cart_M("CartName")%>&CustId=<%=Cart_M("CustId")%>&CustPlant=<%=Cart_M("CustPlant")%>">
          <area shape="rect" coords="121,2,210,23" href="Instructions_List.asp?CartName=<%=Cart_M("CartName")%>&CustId=<%=Cart_M("CustId")%>&CustPlant=<%=Cart_M("CustPlant")%>">
          </map>
        </td>
      </tr>
      <tr>
        <td bordercolor="#FFFFFF"><table width="96%" border="1">
          <tr><td height="51">

<%
'Delete files existing in "\\DB_Server\UGN_DB\TEST_MainMenu\rfc\reports\rtmp\" for current RFC record each time the user enters this screen
'Dim objFSO, objFile, objFolder
'Set objFSO = CreateObject("Scripting.FileSystemObject")
'Set objFolder = objFSO.GetFolder(server.mappath("./reports/rtmp"))
'For Each objFile in objFolder.Files
'      If ( Left(objFile.Name,InStr(objFile.Name,"_")-1)  = Request.QueryString("RFQNo") ) Then
'            objFSO.DeleteFile(Server.MapPath("./reports/rtmp/" & objFile.Name))
'      End If
'Next
' ****************************************************
' Change the value of the variable below to the pathname
' of a directory with write permissions, for example "C:\Inetpub\wwwroot"
  Dim uploadsDirVar
  ''''''''''uploadsDirVar = "D:\ugn_db\TEST_MainMenu\rfc\reports\rtmp"
  uploadsDirVar = "C:\"  
' ****************************************************

' Note: this file uploadTester.asp is just an example to demonstrate
' the capabilities of the freeASPUpload.asp class. There are no plans
' to add any new features to uploadTester.asp itself. Feel free to add
' your own code. If you are building a content management system, you
' may also want to consider this script: http://www.webfilebrowser.com/

function OutputForm()
%>
<br>
              <form name="form2" method="POST" enctype="multipart/form-data" onSubmit="return filetypecheck()" action="Picture_Upload.asp?CartName=<%=Request.QueryString("CartName")%>&CustId=<%=Request.QueryString("CustId")%>&CustPlant=<%=Request.QueryString("CustPlant")%>">
             
                <p>File to Upload: <input name="attach1" type="file" onchange="checkfiletype(this.value)" size=80><br>                <br>
                        <input name="UploadButton" type="submit" style="margin-top:2" value="Upload" >
                        <input name="Submit2" type="hidden" onClick="MM_goToURL('parent','RFC_Update.asp?RFQNo=<%=Request.QueryString("RFQNo")%>&rf=<%=Request.QueryString("rf")%>&orig=<%=Request.QueryString("orig")%>&qe=<%=Request.QueryString("qe")%>&co=<%=Request.QueryString("co")%>&cd=<%=Request.QueryString("cd")%>&sa=<%=Request.QueryString("sa")%>');return document.MM_returnValue" value="Cancel">
                <%
                              Response.Write ("<script language='JavaScript'>checkfieldsform2();</script>")      
                        %>
                </p>
                <p>
                  <input type="image" border="0" name="imageField" src="file.asp?Cartname=<%=Request.QueryString("Cartname")%>&CustId=<%=Request.QueryString("CustId")%>&CustPlant=<%=Request.QueryString("CustPlant")%>" width="600" height="400" >
</p>
          </form>
<br>
<%
end function

function TestEnvironment()
    Dim fso, fileName, testFile, streamTest
    TestEnvironment = ""
    Set fso = Server.CreateObject("Scripting.FileSystemObject")
    if not fso.FolderExists(uploadsDirVar) then
        TestEnvironment = "<B>Folder " & uploadsDirVar & " does not exist.</B><br>The value of your uploadsDirVar is incorrect. Open uploadTester.asp in an editor and change the value of uploadsDirVar to the pathname of a directory with write permissions."
        exit function
    end if
    fileName = uploadsDirVar & "\test.txt"
    on error resume next
    Set testFile = fso.CreateTextFile(fileName, true)
    If Err.Number<>0 then
        TestEnvironment = "<B>Folder " & uploadsDirVar & " does not have write permissions.</B><br>The value of your uploadsDirVar is incorrect. Open uploadTester.asp in an editor and change the value of uploadsDirVar to the pathname of a directory with write permissions."
        exit function
    end if
    Err.Clear
    testFile.Close
    fso.DeleteFile(fileName)

    If Err.Number<>0 then
        TestEnvironment = "<B>Folder " & uploadsDirVar & " does not have delete permissions</B>, although it does have write permissions.<br>Change the permissions for IUSR_<I>computername</I> on this folder."
        exit function
    end if
      Err.Clear
      
    Set streamTest = Server.CreateObject("ADODB.Stream")
    If Err.Number<>0 then
        TestEnvironment = "<B>The ADODB object <I>Stream</I> is not available in your server.</B><br>Check the Requirements page for information about upgrading your ADODB libraries."
        exit function
    end if
    Set streamTest = Nothing
end function

function SaveFiles
    Dim Upload, fileName, fileSize, ks, i, fileKey

    Set Upload = New FreeASPUpload
    Upload.Save(uploadsDirVar)


      'createing File system Object
      Set fso = Server.CreateObject("Scripting.FileSystemObject")
                  
      'Delete older files
    fileName = uploadsDirVar & "drawing.jpg"
      if (fso.FileExists(FileName) = TRUE) then
          fso.DeleteFile(FileName)
      End if
    fileName = uploadsDirVar & "drawing.bmp"
      if (fso.FileExists(FileName) = TRUE) then
          fso.DeleteFile(FileName)
      End if                  


    SaveFiles = ""
    ks = Upload.UploadedFiles.keys
    if (UBound(ks) <> -1) then
        SaveFiles = "<B>Files uploaded:</B> "
        for each fileKey in Upload.UploadedFiles.keys
                  If SaveFiles = "" Then
                        SaveFiles = Upload.UploadedFiles(fileKey).FileName & " (" & Upload.UploadedFiles(fileKey).Length & "B) " & chr(10)
                        'SaveFiles = "drawing.jpg" & " (" & Upload.UploadedFiles(fileKey).Length & "B) " & chr(10)                        
                  Else
                  SaveFiles = SaveFiles & ";  " & Upload.UploadedFiles(fileKey).FileName & " (" & Upload.UploadedFiles(fileKey).Length & "B) " & chr(10)
                        'SaveFiles = SaveFiles & ";  " & "drawing.jpg" & " (" & Upload.UploadedFiles(fileKey).Length & "B) " & chr(10)                        
                  End If
                  
                  
                  If ( LCase(Right(Upload.UploadedFiles(fileKey).FileName,3)) = "jpg" ) Then
                      fileName = uploadsDirVar & Upload.UploadedFiles(fileKey).FileName
                        fileName2 = "C:\drawing.jpg"
                        fso.CopyFile fileName, fileName2, True
                        if (fso.FileExists(FileName) = TRUE) then
                            fso.DeleteFile(FileName)
                        end if
                  ElseIf ( lCase(Right(Upload.UploadedFiles(fileKey).FileName,3)) = "bmp" ) Then
                      fileName = uploadsDirVar & Upload.UploadedFiles(fileKey).FileName
                        fileName2 = "C:\drawing.bmp"
                        fso.CopyFile fileName, fileName2, True
                        if (fso.FileExists(FileName) = TRUE) then
                            fso.DeleteFile(FileName)
                        end if
                        
                        'Converting C:\drawing.bmp to C:\drawing.jpg
                        Set Executor = Server.CreateObject("ASPExec.Execute")
                        Executor.Application = "D:\UGN_DB\Test_MainMenu\Packaging\vbJPGc3.exe"
                        Executor.ShowWindow = True
                        strResult = Executor.ExecuteWinApp                        
      
                        'After converting to  C:\drawing.jpg. Deleting the C:\drawing.bmp
                        if (fso.FileExists(FileName2) = TRUE) then
                            fso.DeleteFile(FileName2)
                        end if
                        
                  End If
                  
        Next
    else
        SaveFiles = "The file name specified in the upload form does not correspond to a valid file in the system."
    end if
end function
%>      
<%
Dim diagnostics
if Request.ServerVariables("REQUEST_METHOD") <> "POST" then
    diagnostics = TestEnvironment()
    if diagnostics<>"" then
        response.write "<div style=""margin-left:10; margin-top:30; margin-right:30; margin-bottom:20;"">"
        response.write diagnostics
        response.write "<p>After you correct this problem, reload the page."
        response.write "</div>"
    else
        response.write "<div style=""margin-left:10"">"
        OutputForm()
        response.write "</div>"
    end if
else
    response.write "<div style=""margin-left:10"">"
    OutputForm()
    response.write SaveFiles()
    response.write "<br><br></div>"
      
      response.redirect("insert_from_disk.asp?CartName=" & Request.QueryString("CartName") & "&CustId=" & Request.QueryString("CustId") & "&CustPlant=" & Request.QueryString("CustPlant") )

      
end if


%>       


              </td>
          </tr>
        </table>
          <p>&nbsp;</p></td>
      </tr>
    </table>      <p>&nbsp;</p>
    </td>

  </tr>
</table>
<!-- InstanceEndEditable --><br>
<table width="100%" border="0" cellspacing="0" cellpadding="2" bgcolor="#CCCCCC">
  <tr>
    <td width="23%"> <font size="-3" face="Verdana, Arial, Helvetica, sans-serif">&copy;2003
    UGN, Inc. </font></td>
    <td width="77%" align="right">&nbsp;</td>
  </tr>
</table>
</body>
<!-- InstanceEnd --></html>
<%
Cart_M.Close()
Set Cart_M = Nothing
%>
<%
Cust_M.Close()
Set Cust_M = Nothing
%>
<%
Cust_Plant_M.Close()
Set Cust_Plant_M = Nothing
%>
<%
Employee_M.Close()
Set Employee_M = Nothing
%>
<%
Container_M.Close()
Set Container_M = Nothing
%>
<%
UGN_Facility_M.Close()
Set UGN_Facility_M = Nothing
%>
<%
UGN_Dept_M.Close()
Set UGN_Dept_M = Nothing
%>

----------------------------

<!--#include file="Loader.asp"-->
<%
      Response.Buffer = True

      ' load object
      Dim load
            Set load = new Loader
            
            ' calling initialize method
            load.initialize
            
      ' File binary data
      Dim fileData
            fileData = load.getFileData("c:\drawing.jpg")
      ' File name
      Dim fileName
            fileName = LCase(load.getFileName("c:\drawing.jpg"))
      ' File path
      Dim filePath
            filePath = load.getFilePath("c:\drawing.jpg")
      ' File path complete
      Dim filePathComplete
            filePathComplete = load.getFilePathComplete("c:\drawing.jpg")
      ' File size
      Dim fileSize
            fileSize = load.getFileSize("c:\drawing.jpg")
      ' File size translated
      Dim fileSizeTranslated
            fileSizeTranslated = load.getFileSizeTranslated("c:\drawing.jpg")
      ' Content Type
      Dim contentType
            contentType = load.getContentType("c:\drawing.jpg")
      ' No. of Form elements
      Dim countElements
            countElements = load.Count

      '' Value of text input field "fname"
      'Dim fnameInput
      '      fnameInput = load.getValue("fname")
      '' Value of text input field "lname"
      'Dim lnameInput
      '      lnameInput = load.getValue("lname")
      '' Value of text input field "profession"
      'Dim profession
      '      profession = load.getValue("profession")      

      ' destroying load object
      Set load = Nothing
%>

<html>
<head>
      <title>Inserts Images into Database</title>
      <style>
            body, input, td { font-family:verdana,arial; font-size:10pt; }
      </style>
</head>
<body>
      <p align="center">
            <b>Inserting Binary Data into Database</b><br>
            <a href="show.asp">To see inserted data click here</a>
      </p>
      
<%

      CartName = Request.QueryString("CartName")
      CustId = Request.QueryString("CustId")
      CustPlant = Request.QueryString("CustPlant")
      'UploadedFile = Request.form("File")
      
%>
      
      
      <table width="700" border="1" align="center">
      <tr>
            <td>File Name</td><td><%= fileName %></td>
      </tr><tr>
            <td>File Path</td><td><%= filePath %></td>
      </tr><tr>
            <td>File Size</td><td><%= fileSize %></td>
            <td>File Path Complete</td><td><%= filePathComplete %></td>
      </tr><tr>
      </tr><tr>
            <td>File Size Translated</td><td><%= fileSizeTranslated %></td>
      </tr><tr>
            <td>Content Type</td><td><%= contentType %></td>
      </tr><tr>
            <td>No. of Form Elements</td><td><%= countElements %></td>
      </tr>
      </table><br><br>
      
      <p style="padding-left:220;">
      <%= fileName %> data received ...<br>

<%

      Response.write("Hello CartName = " & CartName & ", CustId = " & CustId & ", CustPlant = " & CustPlant & ", UploadedFile = " & UploadedFile)
      Response.end
%>

      <%
            ' Checking to make sure if file was uploaded
            If fileSize > 0 Then
            
                  ' Connection string
                  Dim connStr
                        set connStr = Server.CreateObject("ADODB.Connection")                  
                        'connStr = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & Server.MapPath("FileDB.mdb")
                        connStr.open =  "dsn=Test_UGN_DB_DSN;uid=sa;pwd=arihant;"
            
                  ' Recordset object
                  Dim rs
                        Set rs = Server.CreateObject("ADODB.Recordset")
                        
                        'rs.Open "Files", connStr, 2, 2
                        sqltext = "select cartname, contenttypepicture3, Picture3Size, Picture3 from Cart_M where CartName = '" & CartName & "' and Cart_M.CustId = " & CustId & " and Cart_M.CustPlant = '" & CustPlant & "'"
                    rs.Open sqltext, connStr, 2, 4
                        
                        'response.write("sqltext = " & sqltext & ", fileSize = " & fileSize & ", contentType " & contentType )
                        'response.end
                        
                        ' Adding data
                        'rs.AddNew
                              rs("Picture3Size") = fileSize
                              rs("Picture3").AppendChunk fileData
                              rs("contenttypepicture3") = contentType
                        rs.UpdateBatch
                        
                        rs.Close
                        Set rs = Nothing
                        
                  Response.Write "<font color=""green"">File was successfully uploaded...</font>"
            Else
                  Response.Write "<font color=""brown"">No file was selected for uploading...</font>"
            End If
                  
                  
            If Err.number <> 0 Then
                  Response.Write "<br><font color=""red"">Something went wrong...</font>"
            End If
            
            response.redirect("Picture_Upload.asp?CartName=" & CartName & "&CustId=" & CustId & "&CustPlant=" & CustPlant )
            
      %>
      </p>

      <br>

</body>
</html>
------------------------------

UploadFile.asp

<%
'  For examples, documentation, and your own free copy, go to:
'  http://www.freeaspupload.net
'  Note: You can copy and use this script for free and you can make changes
'  to the code, but you cannot remove the above comment.

Class FreeASPUpload
      Public UploadedFiles
      Public FormElements

      Private VarArrayBinRequest
      Private StreamRequest
      Private uploadedYet

      Private Sub Class_Initialize()
            Set UploadedFiles = Server.CreateObject("Scripting.Dictionary")
            Set FormElements = Server.CreateObject("Scripting.Dictionary")
            Set StreamRequest = Server.CreateObject("ADODB.Stream")
            StreamRequest.Type = 1 'adTypeBinary
            StreamRequest.Open
            uploadedYet = false
      End Sub
      
      Private Sub Class_Terminate()
            If IsObject(UploadedFiles) Then
                  UploadedFiles.RemoveAll()
                  Set UploadedFiles = Nothing
            End If
            If IsObject(FormElements) Then
                  FormElements.RemoveAll()
                  Set FormElements = Nothing
            End If
            StreamRequest.Close
            Set StreamRequest = Nothing
      End Sub

      Public Property Get Form(sIndex)
            Form = ""
            If FormElements.Exists(LCase(sIndex)) Then Form = FormElements.Item(LCase(sIndex))
      End Property

      Public Property Get Files()
            Files = UploadedFiles.Items
      End Property

      'Calls Upload to extract the data from the binary request and then saves the uploaded files
      Public Sub Save(path)
            Dim streamFile, fileItem

            if Right(path, 1) <> "\" then path = path & "\"

            if not uploadedYet then Upload


            For Each fileItem In UploadedFiles.Items
                  Set streamFile = Server.CreateObject("ADODB.Stream")
                  streamFile.Type = 1
                  streamFile.Open
                  StreamRequest.Position=fileItem.Start
                  StreamRequest.CopyTo streamFile, fileItem.Length
                  streamFile.SaveToFile path & fileItem.FileName, 2
                  streamFile.close
                  Set streamFile = Nothing
                  fileItem.Path = path & fileItem.FileName
             Next
      End Sub

      Public Function SaveBinRequest(path) ' For debugging purposes
            StreamRequest.SaveToFile path & "\debugStream.bin", 2
      End Function

      Public Sub DumpData() 'only works if files are plain text
            Dim i, aKeys, f
            response.write "Form Items:<br>"
            aKeys = FormElements.Keys
            For i = 0 To FormElements.Count -1 ' Iterate the array
                  response.write aKeys(i) & " = " & FormElements.Item(aKeys(i)) & "<BR>"
            Next
            response.write "Uploaded Files:<br>"
            For Each f In UploadedFiles.Items
                  response.write "Name: " & f.FileName & "<br>"
                  response.write "Type: " & f.ContentType & "<br>"
                  response.write "Start: " & f.Start & "<br>"
                  response.write "Size: " & f.Length & "<br>"
             Next
         End Sub

      Private Sub Upload()
            Dim nCurPos, nDataBoundPos, nLastSepPos
            Dim nPosFile, nPosBound
            Dim sFieldName, osPathSep, auxStr

            'RFC1867 Tokens
            Dim vDataSep
            Dim tNewLine, tDoubleQuotes, tTerm, tFilename, tName, tContentDisp, tContentType
            tNewLine = Byte2String(Chr(13))
            tDoubleQuotes = Byte2String(Chr(34))
            tTerm = Byte2String("--")
            tFilename = Byte2String("filename=""")
            tName = Byte2String("name=""")
            tContentDisp = Byte2String("Content-Disposition")
            tContentType = Byte2String("Content-Type:")

            uploadedYet = true

            VarArrayBinRequest = Request.BinaryRead(Request.TotalBytes)

            nCurPos = FindToken(tNewLine,1) 'Note: nCurPos is 1-based (and so is InstrB, MidB, etc)

            If nCurPos <= 1  Then Exit Sub
             
            'vDataSep is a separator like -----------------------------21763138716045
            vDataSep = MidB(VarArrayBinRequest, 1, nCurPos-1)

            'Start of current separator
            nDataBoundPos = 1

            'Beginning of last line
            nLastSepPos = FindToken(vDataSep & tTerm, 1)

            Do Until nDataBoundPos = nLastSepPos
                  
                  nCurPos = SkipToken(tContentDisp, nDataBoundPos)
                  nCurPos = SkipToken(tName, nCurPos)
                  sFieldName = ExtractField(tDoubleQuotes, nCurPos)

                  nPosFile = FindToken(tFilename, nCurPos)
                  nPosBound = FindToken(vDataSep, nCurPos)
                  
                  If nPosFile <> 0 And  nPosFile < nPosBound Then
                        Dim oUploadFile
                        Set oUploadFile = New UploadedFile
                        
                        nCurPos = SkipToken(tFilename, nCurPos)
                        auxStr = ExtractField(tDoubleQuotes, nCurPos)
                ' We are interested only in the name of the file, not the whole path
                ' Path separator is \ in windows, / in UNIX
                ' While IE seems to put the whole pathname in the stream, Mozilla seem to
                ' only put the actual file name, so UNIX paths may be rare. But not impossible.
                osPathSep = "\"
                if InStr(auxStr, osPathSep) = 0 then osPathSep = "/"
                        oUploadFile.FileName = Right(auxStr, Len(auxStr)-InStrRev(auxStr, osPathSep))

                        if (Len(oUploadFile.FileName) > 0) then 'File field not left empty
                              nCurPos = SkipToken(tContentType, nCurPos)
                              
                    auxStr = ExtractField(tNewLine, nCurPos)
                    ' NN on UNIX puts things like this in the streaa:
                    '    ?? python py type=?? python application/x-python
                              oUploadFile.ContentType = Right(auxStr, Len(auxStr)-InStrRev(auxStr, " "))
                              nCurPos = FindToken(tNewLine, nCurPos) + 4 'skip empty line
                              
                              oUploadFile.Start = nCurPos-1
                              oUploadFile.Length = FindToken(vDataSep, nCurPos) - 2 - nCurPos
                              
                              If oUploadFile.Length > 0 Then UploadedFiles.Add LCase(sFieldName), oUploadFile
                        End If
                  Else
                        Dim nEndOfData
                        nCurPos = FindToken(tNewLine, nCurPos) + 4 'skip empty line
                        nEndOfData = FindToken(vDataSep, nCurPos) - 2
                        If Not FormElements.Exists(LCase(sFieldName)) Then FormElements.Add LCase(sFieldName), String2Byte(MidB(VarArrayBinRequest, nCurPos, nEndOfData-nCurPos))
                  End If

                  'Advance to next separator
                  nDataBoundPos = FindToken(vDataSep, nCurPos)
            Loop
            StreamRequest.Write(VarArrayBinRequest)
      End Sub

      Private Function SkipToken(sToken, nStart)
            SkipToken = InstrB(nStart, VarArrayBinRequest, sToken)
            If SkipToken = 0 then
                  Response.write "Error in parsing uploaded binary request."
                  Response.End
            end if
            SkipToken = SkipToken + LenB(sToken)
      End Function

      Private Function FindToken(sToken, nStart)
            FindToken = InstrB(nStart, VarArrayBinRequest, sToken)
      End Function

      Private Function ExtractField(sToken, nStart)
            Dim nEnd
            nEnd = InstrB(nStart, VarArrayBinRequest, sToken)
            If nEnd = 0 then
                  Response.write "Error in parsing uploaded binary request."
                  Response.End
            end if
            ExtractField = String2Byte(MidB(VarArrayBinRequest, nStart, nEnd-nStart))
      End Function

      'String to byte string conversion
      Private Function Byte2String(sString)
            Dim i
            For i = 1 to Len(sString)
               Byte2String = Byte2String & ChrB(AscB(Mid(sString,i,1)))
            Next
      End Function

      'Byte string to string conversion
      Private Function String2Byte(bsString)
            Dim i
            String2Byte =""
            For i = 1 to LenB(bsString)
               String2Byte = String2Byte & Chr(AscB(MidB(bsString,i,1)))
            Next
      End Function
End Class

Class UploadedFile
      Public ContentType
      Public Start
      Public Length
      Public Path
      Private nameOfFile

    ' Need to remove characters that are valid in UNIX, but not in Windows
    Public Property Let FileName(fN)
        nameOfFile = fN
        nameOfFile = SubstNoReg(nameOfFile, "\", "_")
        nameOfFile = SubstNoReg(nameOfFile, "/", "_")
        nameOfFile = SubstNoReg(nameOfFile, ":", "_")
        nameOfFile = SubstNoReg(nameOfFile, "*", "_")
        nameOfFile = SubstNoReg(nameOfFile, "?", "_")
        nameOfFile = SubstNoReg(nameOfFile, """", "_")
        nameOfFile = SubstNoReg(nameOfFile, "<", "_")
        nameOfFile = SubstNoReg(nameOfFile, ">", "_")
        nameOfFile = SubstNoReg(nameOfFile, "|", "_")
    End Property

    Public Property Get FileName()
        FileName = Request.QueryString("RFQNo") & "_" & nameOfFile
    End Property

    'Public Property Get FileN()ame
End Class


' Does not depend on RegEx, which is not available on older VBScript
' Is not recursive, which means it will not run out of stack space
Function SubstNoReg(initialStr, oldStr, newStr)
    Dim currentPos, oldStrPos, skip
    If IsNull(initialStr) Or Len(initialStr) = 0 Then
        SubstNoReg = ""
    ElseIf IsNull(oldStr) Or Len(oldStr) = 0 Then
        SubstNoReg = initialStr
    Else
        If IsNull(newStr) Then newStr = ""
        currentPos = 1
        oldStrPos = 0
        SubstNoReg = ""
        skip = Len(oldStr)
        Do While currentPos <= Len(initialStr)
            oldStrPos = InStr(currentPos, initialStr, oldStr)
            If oldStrPos = 0 Then
                SubstNoReg = SubstNoReg & Mid(initialStr, currentPos, Len(initialStr) - currentPos + 1)
                currentPos = Len(initialStr) + 1
            Else
                SubstNoReg = SubstNoReg & Mid(initialStr, currentPos, oldStrPos - currentPos) & newStr
                currentPos = oldStrPos + skip
            End If
        Loop
    End If
End Function
%>

----
I want to do something in insert_from_disk.asp . So, it can pick up data from Server Hard disk. c:\drawing.jpg is server location.
        fileData = load.getFileData("c:\drawing.jpg")

Thanks for your patience...............


This link has a tutorial on how to read a binary (image) file and insert it into the database.  I'm sure you'll find the procedure you need to plug into your code there.
http://www.stardeveloper.com/articles/display.html?article=2001033101&page=1

Good luck!
JM
Avatar of nurbek
use free third party components
http://www.aspsmart.com/aspSmartUpload/

you can directly upload picture to database (5 steps in one :)))
also this is the most long posting
i have seen in EE :)
Here is a simple function i used with AspImage

PutIn("C:\temp\_002.png")

Function PutIn(filepath)

  Set Image = Server.CreateObject("AspImage.Image")
  Image.LoadImage(filepath)

      Set objRS = Server.CreateObject("ADODB.Recordset")
      objRS.Open "SELECT * FROM images", dbConnStr, 1, 3
      objRS.AddNew
      objRS("Image1").Value = Image.Image
      objRS.Update
      Set objRS = Nothing

  Set Image = nothing

End Function
Avatar of vsshah

ASKER

Hello mk_b,

I tried your solution. I downloaded/registered ASPImage at client machine as well as Server. and modified my code as below. Code is executing fine without error. But some how I can not see any image. What's wrong in code.

            'C:\drawing.jpg is available now.
            Dim connStr
            set connStr = Server.CreateObject("ADODB.Connection")                  
            connStr.open =  "dsn=Test_UGN_DB_DSN;uid=sa;pwd=arihant;"
            
            Set Image = Server.CreateObject("AspImage.Image")
            Image.LoadImage("C:\drawing.jpg")
                  Set objRS = Server.CreateObject("ADODB.Recordset")
                  sqltext = "select cartname, contenttypepicture3, Picture3Size, Picture3 from Cart_M where CartName = '" & Request.QueryString("CartName") & "' and Cart_M.CustId = " & Request.QueryString("CustId") & " and Cart_M.CustPlant = '" & Request.QueryString("CustPlant") & "'"
                  objRS.Open sqltext, connStr, 2, 4
                  'objRS.AddNew
                  objRS("Picture3").Value = Image.Image
                  objRS("contenttypepicture3") = "image/pjpeg"
                  'objRS.Update
                  objRS.UpdateBatch
                  Set objRS = Nothing
            Set Image = nothing


Thanks,

Vishal.
Avatar of vsshah

ASKER

jmelika,

I already used stardeveloper's solution. But that will work if I am selecting file from browser. and uploading to database.

While my problem is to pick up the file from Server hard disk and upload it to database. I dont know how to modify 'UploadFile.asp' and 'Loader.asp'. I think, by using/modifying dictionary object in those, I can solve my prbolem.

Anyway thanks for suggestion.
Avatar of vsshah

ASKER

nurbek,

I registered aspsmartupload.dll.

But, I dont find any code on their website, how to pickup idle file from Server Hard Disk and send/upload it to database ?
I dont want to pickup file from Browser and upload it to database. I want to pickup readymade .jpg file from Server and upload it to database.

Thanks,
what do you mean by "But some how I can not see any image" in the database you wont see any image...
modify the code below to view the file in asp.



Function GetOut(Id)

        Dim rs
      Set rs = Server.CreateObject("ADODB.Recordset")
      rs.Open "select Image1 from images where Id = "& Id &"", dbConnStr, 1, 2
      If Not rs.EOF Then
            Response.ContentType = "image/png"
            Response.BinaryWrite rs("Image1")
      End If
      rs.Close
      Set rs = Nothing

End Function
Avatar of vsshah

ASKER

mk_b,

I can not see 'picture3' field filled with any value in the table. It shows NULL in table. Well, I can see 'contenttypepicture3' field with value 'image/pjpeg'.
Normally 'picture3' shows Hexadecimal values, if picture is uploaded in reality. 'picture3' datatype is IMAGE datatype.

I am displaying picture on page using

     <input type="image" border="0" name="imageField" src="file.asp?Cartname=<%=Request.QueryString("Cartname")%>&CustId=<%=Request.QueryString("CustId")%>&CustPlant=<%=Request.QueryString("CustPlant")%>" width="600" height="400" >

Where File.asp file is used. file.asp is taken from www.stardeveloper.com since long time back.




I made this script and it works fine "Image1" is a image field in sql2000 and OLE Object in access and it works fine in both of them??? just change the conn properties below and test th script??

<%

Dim dbConnStr
'dbConnStr = "DRIVER={Microsoft Access Driver (*.mdb)};DBQ="& Server.MapPath("data.mdb") &";DefaultDir="& Server.MapPath(".") &";pwd=;DriverId=25;FIL=MS Access"

'--local
dbConnStr = "PROVIDER=MSDASQL;DRIVER={SQL Server};SERVER=MARKB;DATABASE=Northwind;UID=User;PWD=Password;"


Function PutIn(filepath)

  Set Image = Server.CreateObject("AspImage.Image")
  Image.LoadImage(filepath)

      Set objRS = Server.CreateObject("ADODB.Recordset")
      objRS.Open "SELECT * FROM images", dbConnStr, 1, 3
      objRS.AddNew
      objRS("Image1").Value = Image.Image
      objRS.Update
      Set objRS = Nothing

  Set Image = nothing

End Function


Function GetOut(Id)

        Dim rs
      Set rs = Server.CreateObject("ADODB.Recordset")
      rs.Open "select Image1 from images where Id = 1", dbConnStr, 1, 2
      If Not rs.EOF Then
            Response.ContentType = "image/png"
            Response.BinaryWrite rs("Image1")
      End If
      rs.Close
      Set rs = Nothing

End Function


%>


<%

If Request.Form("Add")="yes" Then
  'Server.MapPath(img)
  PutIn("C:\temp\_002.png")
End If


If Request.Form("view")="yes" Then
  GetOut(1)
End If

%>


<form action="tmp.asp" method="post">
Add: <input type="checkbox" name="Add" value="yes"><br>
View: <input type="checkbox" name="View" value="yes"><br>

<input type="submit" name="submit" value="do-it">
</form>
Avatar of vsshah

ASKER

MK_B,

I created page as below. Well, upload is still not working. I created table in my database as below.

Create table images
(id int,
image1 image)

Well, If I upload record in this table using someother way like :
    Insert into images(id,image1) select 1, picture3 from cart_m where cartname = 'MEL-58613-08020'
    Insert into images(id,image1) select 2, picture3 from cart_m where cartname = '58614-0C040'
Then, your GetOut(Id) function works.

But, PutIn(filepath) just insert record with Id value, not a picture.

Do you think, My ASPImage.dll has some problem ?? I just downloaded and registered it at server. Not purchased yet. I was thinking, it will work properly, then my company will purchase it.

Thanks for your so far guidance.
 
----------------------- TestUploadImage.asp ------------------
<%

Dim dbConnStr
'dbConnStr = "DRIVER={Microsoft Access Driver (*.mdb)};DBQ="& Server.MapPath("data.mdb") &";DefaultDir="& Server.MapPath(".") &";pwd=;DriverId=25;FIL=MS Access"

'--local
'dbConnStr = "PROVIDER=MSDASQL;DRIVER={SQL Server};SERVER=MARKB;DATABASE=Northwind;UID=User;PWD=Password;"
            set dbconnStr = Server.CreateObject("ADODB.Connection")                  
            dbconnStr.open =  "dsn=Test_UGN_DB_DSN;uid=sa;pwd=youguess;"


Function PutIn(filepath)

  Set Image = Server.CreateObject("AspImage.Image")
  Image.LoadImage(filepath)

     Set objRS = Server.CreateObject("ADODB.Recordset")
     objRS.Open "SELECT * FROM images", dbConnStr, 1, 3
     objRS.AddNew
     objRS("Image1").Value = Image.Image
     objRS("Id") = 1
     objRS.Update
     Set objRS = Nothing

  Set Image = nothing

End Function


Function GetOut(Id)

     Dim rs
     Set rs = Server.CreateObject("ADODB.Recordset")
     rs.Open "select Image1 from images where Id = " & id, dbConnStr, 1, 2
     If Not rs.EOF Then
          Response.ContentType = "image/png"
          Response.BinaryWrite rs("Image1")
     End If
     rs.Close
     Set rs = Nothing

End Function


%>


<%

If Request.Form("Add")="yes" Then
  'Server.MapPath(img)
  PutIn("C:\drawing.jpg")
End If


If Request.Form("view")="yes" Then
  GetOut(1)
End If

%>


<form action="TestUploadImage.asp" method="post">
Add: <input type="checkbox" name="Add" value="yes"><br>
View: <input type="checkbox" name="View" value="yes"><br>

<input type="submit" name="submit" value="do-it">
</form>
---------------------

ASKER CERTIFIED SOLUTION
Avatar of mk_b
mk_b
Flag of South Africa image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial