Avatar billede lmunch Nybegynder
25. oktober 2001 - 17:14 Der er 6 kommentarer og
1 løsning

Fjerne felt/post fra uploadscript med smartupload

Jeg har prøvet på at fjerne (da jeg ikke skal bruge det) Karakter feltet med radio buttons fra DB og scriptet, men uden held. Nogen som kan hjælpe med det for jeg er kørt fast. Plejer ellers ikke at være et problem for mig:

Default.asp: (indeholder formfelter)
-----------------------------------------------------
<html>
<head>
<title>Nyheds Upload</title>
</head>
<body>


<form action=\"gemNews.asp\" method=\"post\" name=\"form0\" enctype=\"multipart/form-data\">
<!-- enctype=\"multipart/form-data\" skal med ellers virker det ikke -->

<table BGCOLOR=\"#ffffff\" MARGINHEIGHT=\"0\" MARGINWIDTH=\"0\" TOPMARGIN=\"0\" LEFTMARGIN=\"0\" leftmargin=\"0\" Cellpadding=\"0\" Cellspacing=\"0\" Border=\"0\" Width=\"780\" HEIGHT=\"318\"  align=center>

<TR>

    <TD BGCOLOR=\"#ffffff\" WIDTH=780 align=\"center\" valign=\"top\">

<table width=\"800\" border=\"0\"><h1>Nyheds Upload</h1><br><br>
    <tr>
      <td>Her kan du uploade et billede til artiklen.</td>
      <td><input type=\"file\" name=\"file1\"></td>
    </tr><tr>
<tr>
        <td>Indtast dit overskrift:</td>
        <td><input type=\"text\" name=\"headline\" size=\"30\"></td>
    </tr><tr>
        <td width=\"300\">Giv venligst mine sider en karakter:</td>
        <td><tr>
        <td width=\"300\">Giv venligst mine sider en karakter:</td>
        <td><input type=\"radio\" name=\"karakter\" value=\"0\">Xtradårlige<br>
            <input type=\"radio\" name=\"karakter\" value=\"1\">Dårlige<br>
            <input type=\"radio\" name=\"karakter\" value=\"2\">Pø om pø<br>
            <input type=\"radio\" name=\"karakter\" value=\"3\">Gode<br>
            <input type=\"radio\" name=\"karakter\" value=\"4\">Xtragode<br><br>
        </td>
    </tr>

<tr>
        <td>Indtast dato:</td>
        <td><input type=\"text\" name=\"dato\" value=\"<%=(Now)%>\" size=\"30\"></td>
    </tr><tr>
        <td>Indtast artikel:</td>
        <td><textarea name=\"News1\" cols=\"30\" rows=\"5\"></textarea></td>
    </tr><tr>
    <td colspan=\"2\"><input type=\"submit\" value=\"Indryk artikel\"></td>
    </tr>
</table>
</form>
<a href=\"oversigt.asp\">Se andre nyheder --></a>
    </td>
  </tr>
</TABLE>

</body>
</html>


gemNews.asp: (indsætter formfelter + billed i db)
-----------------------------------------------------

<% @Language=\"VBScript\" %>
<% Option Explicit %>
<!-- #include file=\"Adovbs.inc\" -->
<%   
\' Variabler til upload af filer
    Dim mySmartUpload
    Dim intCount
    Dim item
    Dim value
    Dim file
   
\' Variabler til databaseoperationer
    Dim cn
    Dim strSQL
    Dim rs
   
\' Variabler til postsættene
    Dim bytKarak
    Dim strHeadline
    Dim strDato
    Dim strNews1
    Dim strFil
    Dim i
   
\' Her erklæres/instantieres aspSmartUpload objektet
    Set mySmartUpload = Server.CreateObject(\"aspSmartUpload.SmartUpload\")
    mySmartUpload.Upload

\' Her fanges dataene fra formularen på siden default.asp
\' Læg mærke til, at man ikke kan benytte Request.Form, men skal benytte mySmartUpload.Form
    bytKarak = mySmartUpload.Form(\"karakter\")
    strHeadline = mySmartUpload.Form(\"Headline\")
    strDato = mySmartUpload.Form(\"Dato\")
    strNews1 = mySmartUpload.Form(\"News1\")


\'Upload af filer
\'Rettighederne på mappen for IUSR skal være RW
    intCount = mySmartUpload.Save(\"images\")

\'Derefter gemmes alt i databasen NEWS
    Set cn = Server.CreateObject(\"ADODB.Connection\")
    cn.Open \"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=\" & Server.MapPath(\"data/NEWS.mdb\")

    For i = 1 To mySmartUpload.Files.Count
        If mySmartUpload.Files.Item(i).FileName = \"\" Then
        Else
            strFil = mySmartUpload.Files.Item(i).FileName
            strSQL = \"INSERT INTO News (Karakter, Headline, Dato, News1, Billed) \"
            strSQL = strSQL & \"VALUES(\" & bytKarak & \",\'\" & strHeadline & \"\',\'\" & strDato & \"\',\'\" & strNews1
            strSQL = strSQL & \"\',\'\" & strFil & \"\');\"
            cn.Execute strSQL,,adCmdText
        End If
    Next
   
    Response.Redirect(\"oversigt.asp\")
   
%>
</BODY>
</HTML>

Oversigt.asp: (knap så vigtig)
-----------------------------------------------------

<%@ LANGUAGE=\"VBSCRIPT\" %>
<% Option Explicit %>
<!-- #include file=\"./Adovbs.inc\" -->
<%
    Dim bytGennemSnit
    Dim cn
    Dim rs
    Dim strSQL
    Dim i
    Dim strQuote
    strQuote = Chr(34)
    Set cn = Server.CreateObject(\"ADODB.Connection\")
    cn.Open \"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=\" & Server.MapPath(\"data/NEWS.mdb\")
%>   
   
<html>
<head>
<title>Nyheds Upload
</title>

<style type=\"text/css\">
#divLoadCont {position:absolute; z-index:500; left:0px; top:0px; width:100%; height:98%; clip:rect(0px 100% 100% 0px); background-color:#ffffff; layer-background-color:#ffffff;}
#divLoad1    {position:absolute; layer-background-color:silver; background-color:silver;}
#divLoad2    {position:absolute; left:0px; top:0px; layer-background-color:#666666; background-color:#666666;}
#divLoadText {position:absolute; background-color:transparent;font-weight: bold; font-family:verdana,arial,helvetica,sans-serif; color:white; font-size:14px;}
</style>
<script language=\"JavaScript\" type=\"text/javascript\">
/********************************************************************************** 
LoadingBar
*  Copyright (C) 2001 <a href=\"/dhtmlcentral/thomas_brattli.asp\">Thomas Brattli</a>
*  This script was released at DHTMLCentral.com
*  Visit for more great scripts!
*  This may be used and changed freely as long as this msg is intact!
*  We will also appreciate any links you could give us.
*
*  Made by <a href=\"/dhtmlcentral/thomas_brattli.asp\">Thomas Brattli</a>
*********************************************************************************/
function lib_bwcheck(){ //Browsercheck (needed)
    this.ver=navigator.appVersion
    this.agent=navigator.userAgent
    this.dom=document.getElementById?1:0
    this.opera5=(navigator.userAgent.indexOf(\"Opera\")>-1 && document.getElementById)?1:0
    this.ie5=(this.ver.indexOf(\"MSIE 5\")>-1 && this.dom && !this.opera5)?1:0;
    this.ie6=(this.ver.indexOf(\"MSIE 6\")>-1 && this.dom && !this.opera5)?1:0;
    this.ie4=(document.all && !this.dom && !this.opera5)?1:0;
    this.ie=this.ie4||this.ie5||this.ie6
    this.mac=this.agent.indexOf(\"Mac\")>-1
    this.ns6=(this.dom && parseInt(this.ver) >= 5) ?1:0;
    this.ns4=(document.layers && !this.dom)?1:0;
    this.bw=(this.ie6 || this.ie5 || this.ie4 || this.ns4 || this.ns6 || this.opera5)
    return this
}
var bw=new lib_bwcheck()


/*VARIABLES TO SET START: */
numImages = 10    //How many images you have in your page
loaderWidth = 300 //The width of the loadbar
/*
All other settings, like colors fonts and stuff like that you
have to change in the STYLE section.

IMPORTANT:
To make this actually show the correct results
you have to place THIS code in all images:
onload=\"loadIt(1)\"

Which means that your image should look
something like this:
<img src=\"whatever.gif\" width=\"10\" border=\"0\" height=\"10\" onload=\"loadIt(1)\">


VARIABLES TO SET END: */



// A unit of measure that will be added when setting the position of a layer.
var px = bw.ns4||window.opera?\"\":\"px\";

currentImg = 0
//Document size object ********
function lib_doc_size(){
  this.x=0;this.x2=bw.ie && document.body.offsetWidth-20||innerWidth||0;
  this.y=0;this.y2=bw.ie && document.body.offsetHeight-5||innerHeight||0;
  if(!this.x2||!this.y2) return message(\'Document has no width or height\')
  this.x50=this.x2/2;this.y50=this.y2/2;
  return this;
}

//Lib objects  ********************
function lib_obj(obj,nest){
  nest=(!nest) ? \"\":\'document.\'+nest+\'.\'
  this.evnt=bw.dom? document.getElementById(obj):bw.ie4?document.all[obj]:bw.ns4?eval(nest+\"document.layers.\" +obj):0;   
  this.css=bw.dom||bw.ie4?this.evnt.style:this.evnt;
  this.ref=this.css
  this.w=this.evnt.offsetWidth||this.css.clip.width||
    this.ref.width||this.css.pixelWidth||0;
  return this
}
//Moving object to **************
lib_obj.prototype.moveIt = function(x,y){
  this.x=x; this.y=y; this.css.left=x+px; this.css.top=y+px;
}
//Clipping object to ******
lib_obj.prototype.clipTo = function(t,r,b,l,setwidth){
  this.ct=t; this.cr=r; this.cb=b; this.cl=l
  if(bw.ns4){
    this.css.clip.top=t;this.css.clip.right=r
    this.css.clip.bottom=b;this.css.clip.left=l
  }else{
    if(t<0)t=0;if(r<0)r=0;if(b<0)b=0;if(b<0)b=0
    this.css.clip=\"rect(\"+t+\"px \"+r+\"px \"+b+\"px \"+l+\"px)\";
    if (setwidth){
        this.css.pixelWidth = r;
        this.css.pixelHeight = b;
        this.css.width = r+px;
        this.css.height = b+px;
    }
  }
}
var oLoad2
function startLoading(){
  page = new lib_doc_size()
  oLoadCont = new lib_obj(\'divLoadCont\')
  oLoad = new lib_obj(\'divLoad1\',\'divLoadCont\')
  oLoad2 = new lib_obj(\'divLoad2\',\'divLoadCont.document.divLoad1\')
  oLoadText = new lib_obj(\'divLoadText\',\'divLoadCont.document.divLoad1\')
  oLoad.moveIt(page.x50-loaderWidth/2,page.y50-20)
  oLoadText.moveIt(loaderWidth/2 - oLoadText.w/2,10)
  oLoad.clipTo(0,loaderWidth,40,0,1)
  oLoad2.per = loaderWidth/numImages
}
function loadIt(ok){
  currentImg ++
  if (oLoad2) oLoad2.clipTo(0,oLoad2.per*currentImg,40,0,1)
  if (!ok){
    oLoadCont.css.visibility = \"hidden\"
    oLoadCont = null;
    oLoad1 = null;
    oLoad2 = null;
  }
}

//DISPLAY FUNCTION - DELETE START -------- DELETE THIS *************
//LEAVE THIS FUNCTION WHILE TESTING. DELETE WHEN READY
function loadIt_display(ok){
  currentImg ++
  if (oLoad2) oLoad2.clipTo(0,oLoad2.per*currentImg,40,0,1)
  if (currentImg<=numImages) setTimeout(\"loadIt_display(1)\",200)
  else{
    oLoadCont.css.visibility = \"hidden\"
  }
}
//DISPLAY FUNCTION - DELETE END *************************************
</script>

</head>

<body>


<!-- ALWAYS HAVE THIS RIGHT AFTER THE BODY START TAG -->
<div id=\"divLoadCont\">
  <div id=\"divLoad1\">
    <div id=\"divLoad2\"></div><br>
    <div id=\"divLoadText\">Uploading nyhed...</div>
  </div>
</div>
<script>
startLoading()
//onload=loadIt; //- LEAVE THIS LINE WHILE TESTING. UNCOMMENT WHEN READY
loadIt_display(1) //LEAVE THIS LINE WHILE TESTING. DELETE WHEN READY
</script>

<table BGCOLOR=\"#ffffff\" MARGINHEIGHT=\"0\" MARGINWIDTH=\"0\" TOPMARGIN=\"0\" LEFTMARGIN=\"0\" leftmargin=\"0\" Cellpadding=\"0\" Cellspacing=\"0\" Border=\"0\" Width=\"780\" HEIGHT=\"100%\"  align=center>

<TR>

    <TD BGCOLOR=\"#ffffff\" WIDTH=780 align=\"center\" valign=\"top\">

Nyheds oversigt :
        <%    strSQL = \"SELECT Avg(NEWS.Karakter) FROM NEWS;\"
            Set rs = cn.Execute(strSQL,, adCmdText)
            bytGennemSnit = Int(rs(0).value + 0.5)
            Select Case bytGennemSnit
            Case 1
                Response.Write(\"Xtrad&aring;rlige\")
            Case 2
                Response.Write(\"D&aring;rlige\")
            Case 3
                Response.Write(\"P&oslash; om p&oslash;\")
            Case 4
                Response.Write(\"Gode\")
            Case 5
                Response.Write(\"Xtragode\")
            End Select
        Set rs = Nothing
        %>
        <br /><br /> Nyhedens karakter:
<br /><br />
<%    strSQL = \"SELECT NEWS.ID, NEWS.Headline, NEWS.Dato, NEWS.Karakter, NEWS.News1, NEWS.Billed FROM NEWS ORDER BY ID DESC;\"   
    Set rs = cn.Execute(strSQL)
    Do While Not rs.EOF %>
    <% For i = 0 to rs.Fields.Count - 1
        IF rs(i).name = \"Billed\" Then
            Response.Write(\"<img src=\'images/\" & rs(i) & \"\' /><br />\")
        Else
            Response.Write(rs(i).Value & \"<br />\")
        End If
    Next %>
        <br><br>
    <%    RS.MoveNext
Loop

rs.Close
Set rs = Nothing
cn.Close
Set cn = Nothing
%>
<a href=\"default.asp\">Indtast ny artikel--></a>
    </td>
  </tr>
</TABLE>

</body>
</html>


Avatar billede ulrich Novice
25. oktober 2001 - 17:58 #1
Ok..

Default.asp:

<html>
<head>
<title>Nyheds Upload</title>
</head>
<body>


<form action=\"gemNews.asp\" method=\"post\" name=\"form0\" enctype=\"multipart/form-data\">
<!-- enctype=\"multipart/form-data\" skal med ellers virker det ikke -->

<table BGCOLOR=\"#ffffff\" MARGINHEIGHT=\"0\" MARGINWIDTH=\"0\" TOPMARGIN=\"0\" LEFTMARGIN=\"0\" leftmargin=\"0\" Cellpadding=\"0\"

Cellspacing=\"0\" Border=\"0\" Width=\"780\" HEIGHT=\"318\"  align=center>

<TR>

    <TD BGCOLOR=\"#ffffff\" WIDTH=780 align=\"center\" valign=\"top\">

<table width=\"800\" border=\"0\"><h1>Nyheds Upload</h1><br><br>
    <tr>
      <td>Her kan du uploade et billede til artiklen.</td>
      <td><input type=\"file\" name=\"file1\"></td>
    </tr><tr>
<tr>
        <td>Indtast dit overskrift:</td>
        <td><input type=\"text\" name=\"headline\" size=\"30\"></td>
    </tr>
<tr>
        <td>Indtast dato:</td>
        <td><input type=\"text\" name=\"dato\" value=\"<%=(Now)%>\" size=\"30\"></td>
    </tr><tr>
        <td>Indtast artikel:</td>
        <td><textarea name=\"News1\" cols=\"30\" rows=\"5\"></textarea></td>
    </tr><tr>
    <td colspan=\"2\"><input type=\"submit\" value=\"Indryk artikel\"></td>
    </tr>
</table>
</form>
<a href=\"oversigt.asp\">Se andre nyheder --></a>
    </td>
  </tr>
</TABLE>

</body>
</html>


<--------------------->

gemnews.asp

<% @Language=\"VBScript\" %>
<% Option Explicit %>

<%   
\' Variabler til upload af filer
    Dim mySmartUpload
    Dim intCount
    Dim item
    Dim value
    Dim file
   
\' Variabler til databaseoperationer
    Dim cn
    Dim strSQL
    Dim rs
   
\' Variabler til postsættene
    Dim strHeadline
    Dim strDato
    Dim strNews1
    Dim strFil
    Dim i
   
\' Her erklæres/instantieres aspSmartUpload objektet
    Set mySmartUpload = Server.CreateObject(\"aspSmartUpload.SmartUpload\")
    mySmartUpload.Upload

\' Her fanges dataene fra formularen på siden default.asp
\' Læg mærke til, at man ikke kan benytte Request.Form, men skal benytte mySmartUpload.Form
    strHeadline = mySmartUpload.Form(\"Headline\")
    strDato = mySmartUpload.Form(\"Dato\")
    strNews1 = mySmartUpload.Form(\"News1\")


\'Upload af filer
\'Rettighederne på mappen for IUSR skal være RW
    intCount = mySmartUpload.Save(\"images\")

\'Derefter gemmes alt i databasen NEWS
    Set cn = Server.CreateObject(\"ADODB.Connection\")
    cn.Open \"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=\" & Server.MapPath(\"data/NEWS.mdb\")

    For i = 1 To mySmartUpload.Files.Count
        If mySmartUpload.Files.Item(i).FileName = \"\" Then
        Else
            strFil = mySmartUpload.Files.Item(i).FileName
            strSQL = \"INSERT INTO News (Headline, Dato, News1, Billed) \"
            strSQL = strSQL & \"VALUES(\" & strHeadline & \"\',\'\" & strDato & \"\',\'\" & strNews1
            strSQL = strSQL & \"\',\'\" & strFil & \"\');\"
            cn.Execute strSQL,,adCmdText
        End If
    Next
   
    Response.Redirect(\"oversigt.asp\")
   
%>
</BODY>
</HTML>


<--------------------->

oversigt.asp

<%@ LANGUAGE=\"VBSCRIPT\" %>
<% Option Explicit %>
<!-- #include file=\"./Adovbs.inc\" -->
<%
    Dim bytGennemSnit
    Dim cn
    Dim rs
    Dim strSQL
    Dim i
    Dim strQuote
    strQuote = Chr(34)
    Set cn = Server.CreateObject(\"ADODB.Connection\")
    cn.Open \"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=\" & Server.MapPath(\"data/NEWS.mdb\")
%>   
   
<html>
<head>
<title>Nyheds Upload
</title>

<style type=\"text/css\">
#divLoadCont {position:absolute; z-index:500; left:0px; top:0px; width:100%; height:98%; clip:rect(0px 100% 100% 0px);

background-color:#ffffff; layer-background-color:#ffffff;}
#divLoad1    {position:absolute; layer-background-color:silver; background-color:silver;}
#divLoad2    {position:absolute; left:0px; top:0px; layer-background-color:#666666; background-color:#666666;}
#divLoadText {position:absolute; background-color:transparent;font-weight: bold;

font-family:verdana,arial,helvetica,sans-serif; color:white; font-size:14px;}
</style>
<script language=\"JavaScript\" type=\"text/javascript\">
/********************************************************************************** 
LoadingBar
*  Copyright (C) 2001 <a href=\"/dhtmlcentral/thomas_brattli.asp\">Thomas Brattli</a>
*  This script was released at DHTMLCentral.com
*  Visit for more great scripts!
*  This may be used and changed freely as long as this msg is intact!
*  We will also appreciate any links you could give us.
*
*  Made by <a href=\"/dhtmlcentral/thomas_brattli.asp\">Thomas Brattli</a>
*********************************************************************************/
function lib_bwcheck(){ //Browsercheck (needed)
    this.ver=navigator.appVersion
    this.agent=navigator.userAgent
    this.dom=document.getElementById?1:0
    this.opera5=(navigator.userAgent.indexOf(\"Opera\")>-1 && document.getElementById)?1:0
    this.ie5=(this.ver.indexOf(\"MSIE 5\")>-1 && this.dom && !this.opera5)?1:0;
    this.ie6=(this.ver.indexOf(\"MSIE 6\")>-1 && this.dom && !this.opera5)?1:0;
    this.ie4=(document.all && !this.dom && !this.opera5)?1:0;
    this.ie=this.ie4||this.ie5||this.ie6
    this.mac=this.agent.indexOf(\"Mac\")>-1
    this.ns6=(this.dom && parseInt(this.ver) >= 5) ?1:0;
    this.ns4=(document.layers && !this.dom)?1:0;
    this.bw=(this.ie6 || this.ie5 || this.ie4 || this.ns4 || this.ns6 || this.opera5)
    return this
}
var bw=new lib_bwcheck()


/*VARIABLES TO SET START: */
numImages = 10    //How many images you have in your page
loaderWidth = 300 //The width of the loadbar
/*
All other settings, like colors fonts and stuff like that you
have to change in the STYLE section.

IMPORTANT:
To make this actually show the correct results
you have to place THIS code in all images:
onload=\"loadIt(1)\"

Which means that your image should look
something like this:
<img src=\"whatever.gif\" width=\"10\" border=\"0\" height=\"10\" onload=\"loadIt(1)\">


VARIABLES TO SET END: */



// A unit of measure that will be added when setting the position of a layer.
var px = bw.ns4||window.opera?\"\":\"px\";

currentImg = 0
//Document size object ********
function lib_doc_size(){
  this.x=0;this.x2=bw.ie && document.body.offsetWidth-20||innerWidth||0;
  this.y=0;this.y2=bw.ie && document.body.offsetHeight-5||innerHeight||0;
  if(!this.x2||!this.y2) return message(\'Document has no width or height\')
  this.x50=this.x2/2;this.y50=this.y2/2;
  return this;
}

//Lib objects  ********************
function lib_obj(obj,nest){
  nest=(!nest) ? \"\":\'document.\'+nest+\'.\'
  this.evnt=bw.dom? document.getElementById(obj):bw.ie4?document.all[obj]:bw.ns4?eval(nest+\"document.layers.\" +obj):0;   
  this.css=bw.dom||bw.ie4?this.evnt.style:this.evnt;
  this.ref=this.css
  this.w=this.evnt.offsetWidth||this.css.clip.width||
    this.ref.width||this.css.pixelWidth||0;
  return this
}
//Moving object to **************
lib_obj.prototype.moveIt = function(x,y){
  this.x=x; this.y=y; this.css.left=x+px; this.css.top=y+px;
}
//Clipping object to ******
lib_obj.prototype.clipTo = function(t,r,b,l,setwidth){
  this.ct=t; this.cr=r; this.cb=b; this.cl=l
  if(bw.ns4){
    this.css.clip.top=t;this.css.clip.right=r
    this.css.clip.bottom=b;this.css.clip.left=l
  }else{
    if(t<0)t=0;if(r<0)r=0;if(b<0)b=0;if(b<0)b=0
    this.css.clip=\"rect(\"+t+\"px \"+r+\"px \"+b+\"px \"+l+\"px)\";
    if (setwidth){
        this.css.pixelWidth = r;
        this.css.pixelHeight = b;
        this.css.width = r+px;
        this.css.height = b+px;
    }
  }
}
var oLoad2
function startLoading(){
  page = new lib_doc_size()
  oLoadCont = new lib_obj(\'divLoadCont\')
  oLoad = new lib_obj(\'divLoad1\',\'divLoadCont\')
  oLoad2 = new lib_obj(\'divLoad2\',\'divLoadCont.document.divLoad1\')
  oLoadText = new lib_obj(\'divLoadText\',\'divLoadCont.document.divLoad1\')
  oLoad.moveIt(page.x50-loaderWidth/2,page.y50-20)
  oLoadText.moveIt(loaderWidth/2 - oLoadText.w/2,10)
  oLoad.clipTo(0,loaderWidth,40,0,1)
  oLoad2.per = loaderWidth/numImages
}
function loadIt(ok){
  currentImg ++
  if (oLoad2) oLoad2.clipTo(0,oLoad2.per*currentImg,40,0,1)
  if (!ok){
    oLoadCont.css.visibility = \"hidden\"
    oLoadCont = null;
    oLoad1 = null;
    oLoad2 = null;
  }
}

//DISPLAY FUNCTION - DELETE START -------- DELETE THIS *************
//LEAVE THIS FUNCTION WHILE TESTING. DELETE WHEN READY
function loadIt_display(ok){
  currentImg ++
  if (oLoad2) oLoad2.clipTo(0,oLoad2.per*currentImg,40,0,1)
  if (currentImg<=numImages) setTimeout(\"loadIt_display(1)\",200)
  else{
    oLoadCont.css.visibility = \"hidden\"
  }
}
//DISPLAY FUNCTION - DELETE END *************************************
</script>

</head>

<body>


<!-- ALWAYS HAVE THIS RIGHT AFTER THE BODY START TAG -->
<div id=\"divLoadCont\">
  <div id=\"divLoad1\">
    <div id=\"divLoad2\"></div><br>
    <div id=\"divLoadText\">Uploading nyhed...</div>
  </div>
</div>
<script>
startLoading()
//onload=loadIt; //- LEAVE THIS LINE WHILE TESTING. UNCOMMENT WHEN READY
loadIt_display(1) //LEAVE THIS LINE WHILE TESTING. DELETE WHEN READY
</script>

<table BGCOLOR=\"#ffffff\" MARGINHEIGHT=\"0\" MARGINWIDTH=\"0\" TOPMARGIN=\"0\" LEFTMARGIN=\"0\" leftmargin=\"0\" Cellpadding=\"0\"

Cellspacing=\"0\" Border=\"0\" Width=\"780\" HEIGHT=\"100%\"  align=center>

<TR>

    <TD BGCOLOR=\"#ffffff\" WIDTH=780 align=\"center\" valign=\"top\">

Nyheds oversigt :
       
<br /><br />
<%    strSQL = \"SELECT NEWS.ID, NEWS.Headline, NEWS.Dato, NEWS.News1, NEWS.Billed FROM NEWS ORDER BY ID DESC;\"   
    Set rs = cn.Execute(strSQL)
    Do While Not rs.EOF %>
    <% For i = 0 to rs.Fields.Count - 1
        IF rs(i).name = \"Billed\" Then
            Response.Write(\"<img src=\'images/\" & rs(i) & \"\' /><br />\")
        Else
            Response.Write(rs(i).Value & \"<br />\")
        End If
    Next %>
        <br><br>
    <%    RS.MoveNext
Loop

rs.Close
Set rs = Nothing
cn.Close
Set cn = Nothing
%>
<a href=\"default.asp\">Indtast ny artikel--></a>
    </td>
  </tr>
</TABLE>

</body>
</html>

Avatar billede rasmustest Nybegynder
25. oktober 2001 - 17:59 #2
virker den loader?og hvordan?
Avatar billede ulrich Novice
25. oktober 2001 - 18:05 #3
Avatar billede lmunch Nybegynder
25. oktober 2001 - 19:22 #4
saturation : Det der havde jeg selv gjort, de´t er noget andet der skal væk...Får følgende fejl:

Tekniske oplysninger (for supportteknikere)

Fejltype:
Der opstod en Microsoft VBScript-kørselsfejl (0x800A01F4)
Variablen er ikke defineret: \'adCmdText\'
/NyhedsUpload/gemNews.asp, line 50


Browsertype:
Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)

Side:
POST 32164 bytes to /NyhedsUpload/gemNews.asp

POST Data:
fejl \'80020009\'
Undtagelse opstod.

/iisHelp/common/500-100.asp, line 192
Avatar billede ulrich Novice
25. oktober 2001 - 21:40 #5
ok her er en ny version af gemnews.aso

gemnews.asp

<% @Language=\"VBScript\" %>
<% Option Explicit %>

<%   
\' Variabler til upload af filer
    Dim mySmartUpload
    Dim intCount
    Dim item
    Dim value
    Dim file
   
\' Variabler til databaseoperationer
    Dim cn
    Dim strSQL
    Dim rs
   
\' Variabler til postsættene
    Dim strHeadline
    Dim strDato
    Dim strNews1
    Dim strFil
    Dim i
   
\' Her erklæres/instantieres aspSmartUpload objektet
    Set mySmartUpload = Server.CreateObject(\"aspSmartUpload.SmartUpload\")
    mySmartUpload.Upload

\' Her fanges dataene fra formularen på siden default.asp
\' Læg mærke til, at man ikke kan benytte Request.Form, men skal benytte mySmartUpload.Form
    strHeadline = mySmartUpload.Form(\"Headline\")
    strDato = mySmartUpload.Form(\"Dato\")
    strNews1 = mySmartUpload.Form(\"News1\")


\'Upload af filer
\'Rettighederne på mappen for IUSR skal være RW
    intCount = mySmartUpload.Save(\"images\")

\'Derefter gemmes alt i databasen NEWS
    Set cn = Server.CreateObject(\"ADODB.Connection\")
    cn.Open \"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=\" & Server.MapPath(\"data/NEWS.mdb\")

    For i = 1 To mySmartUpload.Files.Count
        If mySmartUpload.Files.Item(i).FileName = \"\" Then
        Else
            strFil = mySmartUpload.Files.Item(i).FileName
            strSQL = \"INSERT INTO News (Headline, Dato, News1, Billed) \"
            strSQL = strSQL & \"VALUES(\" & strHeadline & \"\',\'\" & strDato & \"\',\'\" & strNews1
            strSQL = strSQL & \"\',\'\" & strFil & \"\');\"
            cn.Execute strSQL
        End If
    Next
   
    Response.Redirect(\"oversigt.asp\")
   
%>
</BODY>
</HTML>
Avatar billede ulrich Novice
25. oktober 2001 - 22:00 #6
Svaret vises her til ekspertens brugere :>

default.asp

<html>
<head>
<title>Nyheds Upload</title>
</head>
<body>


<form action=\"gemNews.asp\" method=\"post\" name=\"form0\" enctype=\"multipart/form-data\">
<!-- enctype=\"multipart/form-data\" skal med ellers virker det ikke -->

<table BGCOLOR=\"#ffffff\" MARGINHEIGHT=\"0\" MARGINWIDTH=\"0\" TOPMARGIN=\"0\" LEFTMARGIN=\"0\"

leftmargin=\"0\" Cellpadding=\"0\" Cellspacing=\"0\" Border=\"0\" Width=\"780\" HEIGHT=\"318\"  align=center>

<TR>

    <TD BGCOLOR=\"#ffffff\" WIDTH=780 align=\"center\" valign=\"top\">

<table width=\"800\" border=\"0\"><h1>Nyheds Upload</h1><br><br>
    <tr>
      <td>Her kan du uploade et billede til artiklen.</td>
      <td><input type=\"file\" name=\"file1\"></td>
    </tr><tr>
<tr>
        <td>Indtast dit overskrift:</td>
        <td><input type=\"text\" name=\"headline\" size=\"30\"></td>
    </tr><tr>
        <td width=\"300\">Giv venligst mine sider en karakter:</td>
        <td>

<tr>
        <td>Indtast dato:</td>
        <td><input type=\"text\" name=\"dato\" value=\"<%=(Now)%>\" size=\"30\"></td>
    </tr><tr>
        <td>Indtast artikel:</td>
        <td><textarea name=\"News1\" cols=\"30\" rows=\"5\"></textarea></td>
    </tr><tr>
    <td colspan=\"2\"><input type=\"submit\" value=\"Indryk artikel\"></td>
    </tr>
</table>
</form>
<a href=\"oversigt.asp\">Se andre nyheder --></a>
    </td>
  </tr>
</TABLE>

</body>
</html>



gemnews.asp

<% @Language=\"VBScript\" %>
<% Option Explicit %>
<!-- #include file=\"Adovbs.inc\" -->
<%   
\' Variabler til upload af filer
    Dim mySmartUpload
    Dim intCount
    Dim item
    Dim value
    Dim file
   
\' Variabler til databaseoperationer
    Dim cn
    Dim strSQL
    Dim rs
   
\' Variabler til postsættene
    Dim bytKarak
    Dim strHeadline
    Dim strDato
    Dim strNews1
    Dim strFil
    Dim i
   
\' Her erklæres/instantieres aspSmartUpload objektet
    Set mySmartUpload = Server.CreateObject(\"aspSmartUpload.SmartUpload\")
    mySmartUpload.Upload

\' Her fanges dataene fra formularen på siden default.asp
\' Læg mærke til, at man ikke kan benytte Request.Form, men skal benytte mySmartUpload.Form
    \'bytKarak = mySmartUpload.Form(\"karakter\")
    strHeadline = mySmartUpload.Form(\"Headline\")
    strDato = mySmartUpload.Form(\"Dato\")
    strNews1 = mySmartUpload.Form(\"News1\")


\'Upload af filer
\'Rettighederne på mappen for IUSR skal være RW
    intCount = mySmartUpload.Save(\"images\")

\'Derefter gemmes alt i databasen NEWS
    Set cn = Server.CreateObject(\"ADODB.Connection\")
    cn.Open \"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=\" & Server.MapPath(\"data/NEWS.mdb\")

    For i = 1 To mySmartUpload.Files.Count
        If mySmartUpload.Files.Item(i).FileName = \"\" Then
        Else
            strFil = mySmartUpload.Files.Item(i).FileName
            strSQL = \"INSERT INTO News (Headline, Dato, News1, Billed) \"
            strSQL = strSQL & \"VALUES(\'\" & strHeadline & \"\',\'\" & strDato & \"\',\'\" & strNews1
            strSQL = strSQL & \"\',\'\" & strFil & \"\');\"
            cn.Execute strSQL
        End If
    Next
   
    Response.Redirect(\"oversigt.asp\")
   
%>
</BODY>
</HTML>

oversigt.asp

<%@ LANGUAGE=\"VBSCRIPT\" %>
<% Option Explicit %>
<!-- #include file=\"./Adovbs.inc\" -->
<%
    Dim bytGennemSnit
    Dim cn
    Dim rs
    Dim strSQL
    Dim i
    Dim strQuote
    strQuote = Chr(34)
    Set cn = Server.CreateObject(\"ADODB.Connection\")
    cn.Open \"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=\" & Server.MapPath(\"data/NEWS.mdb\")
%>   
   
<html>
<head>
<title>Nyheds Upload
</title>

<style type=\"text/css\">
#divLoadCont {position:absolute; z-index:500; left:0px; top:0px; width:100%; height:98%; clip:rect(0px 100% 100% 0px);

background-color:#ffffff; layer-background-color:#ffffff;}
#divLoad1    {position:absolute; layer-background-color:silver; background-color:silver;}
#divLoad2    {position:absolute; left:0px; top:0px; layer-background-color:#666666; background-color:#666666;}
#divLoadText {position:absolute; background-color:transparent;font-weight: bold;

font-family:verdana,arial,helvetica,sans-serif; color:white; font-size:14px;}
</style>
<script language=\"JavaScript\" type=\"text/javascript\">
/********************************************************************************** 
LoadingBar
*  Copyright (C) 2001 <a href=\"/dhtmlcentral/thomas_brattli.asp\">Thomas Brattli</a>
*  This script was released at DHTMLCentral.com
*  Visit for more great scripts!
*  This may be used and changed freely as long as this msg is intact!
*  We will also appreciate any links you could give us.
*
*  Made by <a href=\"/dhtmlcentral/thomas_brattli.asp\">Thomas Brattli</a>
*********************************************************************************/
function lib_bwcheck(){ //Browsercheck (needed)
    this.ver=navigator.appVersion
    this.agent=navigator.userAgent
    this.dom=document.getElementById?1:0
    this.opera5=(navigator.userAgent.indexOf(\"Opera\")>-1 && document.getElementById)?1:0
    this.ie5=(this.ver.indexOf(\"MSIE 5\")>-1 && this.dom && !this.opera5)?1:0;
    this.ie6=(this.ver.indexOf(\"MSIE 6\")>-1 && this.dom && !this.opera5)?1:0;
    this.ie4=(document.all && !this.dom && !this.opera5)?1:0;
    this.ie=this.ie4||this.ie5||this.ie6
    this.mac=this.agent.indexOf(\"Mac\")>-1
    this.ns6=(this.dom && parseInt(this.ver) >= 5) ?1:0;
    this.ns4=(document.layers && !this.dom)?1:0;
    this.bw=(this.ie6 || this.ie5 || this.ie4 || this.ns4 || this.ns6 || this.opera5)
    return this
}
var bw=new lib_bwcheck()


/*VARIABLES TO SET START: */
numImages = 10    //How many images you have in your page
loaderWidth = 300 //The width of the loadbar
/*
All other settings, like colors fonts and stuff like that you
have to change in the STYLE section.

IMPORTANT:
To make this actually show the correct results
you have to place THIS code in all images:
onload=\"loadIt(1)\"

Which means that your image should look
something like this:
<img src=\"whatever.gif\" width=\"10\" border=\"0\" height=\"10\" onload=\"loadIt(1)\">


VARIABLES TO SET END: */



// A unit of measure that will be added when setting the position of a layer.
var px = bw.ns4||window.opera?\"\":\"px\";

currentImg = 0
//Document size object ********
function lib_doc_size(){
  this.x=0;this.x2=bw.ie && document.body.offsetWidth-20||innerWidth||0;
  this.y=0;this.y2=bw.ie && document.body.offsetHeight-5||innerHeight||0;
  if(!this.x2||!this.y2) return message(\'Document has no width or height\')
  this.x50=this.x2/2;this.y50=this.y2/2;
  return this;
}

//Lib objects  ********************
function lib_obj(obj,nest){
  nest=(!nest) ? \"\":\'document.\'+nest+\'.\'
  this.evnt=bw.dom? document.getElementById(obj):bw.ie4?document.all[obj]:bw.ns4?eval(nest+\"document.layers.\" +obj):0;   
  this.css=bw.dom||bw.ie4?this.evnt.style:this.evnt;
  this.ref=this.css
  this.w=this.evnt.offsetWidth||this.css.clip.width||
    this.ref.width||this.css.pixelWidth||0;
  return this
}
//Moving object to **************
lib_obj.prototype.moveIt = function(x,y){
  this.x=x; this.y=y; this.css.left=x+px; this.css.top=y+px;
}
//Clipping object to ******
lib_obj.prototype.clipTo = function(t,r,b,l,setwidth){
  this.ct=t; this.cr=r; this.cb=b; this.cl=l
  if(bw.ns4){
    this.css.clip.top=t;this.css.clip.right=r
    this.css.clip.bottom=b;this.css.clip.left=l
  }else{
    if(t<0)t=0;if(r<0)r=0;if(b<0)b=0;if(b<0)b=0
    this.css.clip=\"rect(\"+t+\"px \"+r+\"px \"+b+\"px \"+l+\"px)\";
    if (setwidth){
        this.css.pixelWidth = r;
        this.css.pixelHeight = b;
        this.css.width = r+px;
        this.css.height = b+px;
    }
  }
}
var oLoad2
function startLoading(){
  page = new lib_doc_size()
  oLoadCont = new lib_obj(\'divLoadCont\')
  oLoad = new lib_obj(\'divLoad1\',\'divLoadCont\')
  oLoad2 = new lib_obj(\'divLoad2\',\'divLoadCont.document.divLoad1\')
  oLoadText = new lib_obj(\'divLoadText\',\'divLoadCont.document.divLoad1\')
  oLoad.moveIt(page.x50-loaderWidth/2,page.y50-20)
  oLoadText.moveIt(loaderWidth/2 - oLoadText.w/2,10)
  oLoad.clipTo(0,loaderWidth,40,0,1)
  oLoad2.per = loaderWidth/numImages
}
function loadIt(ok){
  currentImg ++
  if (oLoad2) oLoad2.clipTo(0,oLoad2.per*currentImg,40,0,1)
  if (!ok){
    oLoadCont.css.visibility = \"hidden\"
    oLoadCont = null;
    oLoad1 = null;
    oLoad2 = null;
  }
}

//DISPLAY FUNCTION - DELETE START -------- DELETE THIS *************
//LEAVE THIS FUNCTION WHILE TESTING. DELETE WHEN READY
function loadIt_display(ok){
  currentImg ++
  if (oLoad2) oLoad2.clipTo(0,oLoad2.per*currentImg,40,0,1)
  if (currentImg<=numImages) setTimeout(\"loadIt_display(1)\",200)
  else{
    oLoadCont.css.visibility = \"hidden\"
  }
}
//DISPLAY FUNCTION - DELETE END *************************************
</script>

</head>

<body>


<!-- ALWAYS HAVE THIS RIGHT AFTER THE BODY START TAG -->
<div id=\"divLoadCont\">
  <div id=\"divLoad1\">
    <div id=\"divLoad2\"></div><br>
    <div id=\"divLoadText\">Uploading nyhed...</div>
  </div>
</div>
<script>
startLoading()
//onload=loadIt; //- LEAVE THIS LINE WHILE TESTING. UNCOMMENT WHEN READY
loadIt_display(1) //LEAVE THIS LINE WHILE TESTING. DELETE WHEN READY
</script>

<table BGCOLOR=\"#ffffff\" MARGINHEIGHT=\"0\" MARGINWIDTH=\"0\" TOPMARGIN=\"0\" LEFTMARGIN=\"0\" leftmargin=\"0\" Cellpadding=\"0\"

Cellspacing=\"0\" Border=\"0\" Width=\"780\" HEIGHT=\"100%\"  align=center>

<TR>

    <TD BGCOLOR=\"#ffffff\" WIDTH=780 align=\"center\" valign=\"top\">



<br /><br />
<%    strSQL = \"SELECT NEWS.ID, NEWS.Headline, NEWS.Dato, NEWS.News1, NEWS.Billed FROM NEWS ORDER BY ID DESC;\"   
    Set rs = cn.Execute(strSQL)
    Do While Not rs.EOF %>
    <% For i = 0 to rs.Fields.Count - 1
        IF rs(i).name = \"Billed\" Then
            Response.Write(\"<img src=\'images/\" & rs(i) & \"\' /><br />\")
        Else
            Response.Write(rs(i).Value & \"<br />\")
        End If
    Next %>
        <br><br>
    <%    RS.MoveNext
Loop

rs.Close
Set rs = Nothing
cn.Close
Set cn = Nothing
%>
<a href=\"default.asp\">Indtast ny artikel--></a>
    </td>
  </tr>
</TABLE>

</body>
</html>
Avatar billede lmunch Nybegynder
25. oktober 2001 - 22:11 #7
Mange THX :-)
Avatar billede Ny bruger Nybegynder

Din løsning...

Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.

Loading billede Opret Preview
Kategori
Kurser inden for grundlæggende programmering

Log ind eller opret profil

Hov!

For at kunne deltage på Computerworld Eksperten skal du være logget ind.

Det er heldigvis nemt at oprette en bruger: Det tager to minutter og du kan vælge at bruge enten e-mail, Facebook eller Google som login.

Du kan også logge ind via nedenstående tjenester