Avatar billede kometen79 Nybegynder
12. april 2004 - 03:53 Der er 3 kommentarer og
1 løsning

Hjælp til CMS

Jeg vil gerne have tilføjet nogle data til mit billede upload. På nuværende tidsunkt skriver den kun <img> koden jeg vil gerne gerne kunne tilføje en class samt alignment.
Det her har jeg selv tilføjet:

<select name="alignment" class="form">
                            <option value="right" selected>Venstre</option>
                            <option value="right">Højre</option>
                            <option value="center">Centreret</option>
                    </select>


Koden ser sådan her ud:



strAlignment = Request.form("alignment")



'Intiliase variables
blnExtensionOK = True


'read in the message box type
strMessageBoxType = Request.QueryString("MSG")



'If this is a post back then upload the image
If Request.QueryString("PB") = "Y" Then
   
    'Get the image types to upload
    saryFileUploadTypes = Split(Trim(strImageTypes), ";")
   
    'Call upoload file function
    strImageName = fileUpload(strFileUploadPath, saryFileUploadTypes, intMaxImageSize, strUploadComponent, lngErrorFileSize, blnExtensionOK)

End If


%>
<html>
<head>
<meta name="copyright" content="Copyright (C) 2002-2004 Bruce Corkhill" />
<title>Image Upload</title>

<!-- Web Wiz Rich Text Editor ver. <% = strRTEversion %> is written and produced by Bruce Corkhill ©2002-2004
        If you want your own Rich Text Editor then goto http://www.richtexteditor.org -->

<script  language="JavaScript">
<%
'If the image has been saved then place it in the post
If lngErrorFileSize = 0 AND blnExtensionOK = True AND strImageName <> "" Then

    'If this is Rich text editor and IE5.0 use the exeCommand to place it in the editor
    If strMessageBoxType = "RTE" AND RTEenabled = "winIE5" Then
    %>

    window.opener.frames.message.document.focus();
    window.opener.frames.message.document.execCommand('InsertImage', false, '<% = strFileUploadPath  & "/" & strImageName %>');
    window.close();
<%

    'If this is Rich text editor use the exeCommand to place it in the editor
    ElseIf strMessageBoxType = "RTE" Then
        %>

    window.opener.document.getElementById("message").contentWindow.focus();
    window.opener.document.getElementById("message").contentWindow.document.execCommand('InsertImage', false, '<% = strFileUploadPath  & "/" & strImageName %>');
    window.close();
<%

    'Else if they are using the basic editor place the image path into it
    ElseIf strMessageBoxType = "BSC" Then
        %>
    window.opener.document.frmAddMessage.message.focus();
    window.opener.document.frmAddMessage.message.value += '<img src="<% = strFileUploadPath & "/" & strImageName %>"/>';
    window.close();
<%
    End If
End If
%>
</script>
<link href="includes/default_style.css" rel="stylesheet" type="text/css" />
</head>
<body OnLoad="self.focus(); document.forms.frmImageUp.Submit.disabled=true;"><%

'If the user is allowed to upload then show them the form
If blnImageUpload Then   

    %>
<table width="100%" border="0" align="center" cellpadding="1" cellspacing="0">
<form action="upload_images.asp?MSG=<% = strMessageBoxType %>&PB=Y" method="post" enctype="multipart/form-data" name="frmImageUp" target="_self" id="frmImageUp" onSubmit="alert('<% = strTxtPleaseWaitWhileImageIsUploaded %>')">
  <tr>
  <td width="100%">
    <fieldset>
    <legend><% = strTxtImageUpload %></legend>
    <table width="100%" border="0" cellspacing="0" cellpadding="1">
    <tr>
      <td width="10%" align="right" class="text"><% = strTxtImage %>:</td>
      <td width="90%"><input name="file" class="form" type="file" size="35" onFocus="document.forms.frmImageUp.Submit.disabled=false;" onChange="document.forms.frmImageUp.Submit.disabled=false;" />
        </td>
    </tr>
    <tr>
      <td width="10%" align="right" class="text">Justering:</td>
      <td width="90%"><select name="alignment" class="form">
                            <option value="right" selected>Venstre</option>
                            <option value="right">Højre</option>
                            <option value="center">Centreret</option>
                    </select>
     
     
        </td>
    </tr>
    <tr align="center">
      <td colspan="2" class="text"><br /><%
         
          'If the file upload has failed becuase of the wrong extension display an error message
    If blnExtensionOK = False Then

        Response.Write("<span class=""error"">" & strTxtImageOfTheWrongFileType & ".<br />" & strTxtImagesMustBeOfTheType & ", "  &  Replace(strImageTypes, ";", ", ", 1, -1, 1) & "</span>")

    'Else if the file upload has failed becuase the size is to large display an error message
    ElseIf lngErrorFileSize <> 0 Then

        Response.Write("<span class=""error"">" & strTxtImageFileSizeToLarge & " " & lngErrorFileSize & "KB.<br />" & strTxtMaximumFileSizeMustBe & " " & intMaxImageSize & "KB</span>")
   
    'Else display a message of the image types that can be uploaded
    Else
     
              Response.Write(strTxtImagesMustBeOfTheType & ", " & Replace(strImageTypes, ";", ", ", 1, -1, 1) & ", " & strTxtAndHaveMaximumFileSizeOf & " " & intMaxImageSize & "KB")
         
          End If
      %></td>
    </tr>
    </table>
    </fieldset></td>
  </tr>
  <tr align="right">
  <td> <input type="submit" class="formular" name="Submit" value="    <% = strTxtOK %>    "> &nbsp; <input type="button" class="formular" name="cancel" value=" <% = strTxtCancel %> " onClick="window.close()"></td>
  </tr>
</form>
</table><%

End If

%>
Avatar billede roenving Novice
12. april 2004 - 20:24 #1
Såvidt jeg kan se, handler det da mere om, at du har brug for noget asp-hjælp, for tilføjelserne til formen kan du jo selv klare, men det er vel tilføjelserne i databasen, som mangler for alvor ?-)
Avatar billede kometen79 Nybegynder
16. april 2004 - 11:32 #2
Den smider datane videre til en iframe, men hvordan for jeg den til at lade være med at lave fejl.

Her kan du se selve upload siden, det er her der kommer fejl.

Set objUpload = Server.CreateObject("Persits.Upload.1")

            With objUpload


                'make sure files arn't over written
                .OverwriteFiles = False

                'We need to save the file before we can find out anything about it
                '** Save virtual is used as saving to memory is often disabled by the web host **
                .SaveVirtual strFileUploadPath

                'Get the file name
                strNewFileName = .Files(1).ExtractFileName

                'Replace spaces with underscores
                strNewFileName = Replace(strNewFileName, " ", "_", 1, -1, 1)

                'Remove brackets that aspUpload may put in when renaming a file
                strNewFileName = Replace(strNewFileName, "(", "", 1, -1, 1)
                strNewFileName = Replace(strNewFileName, ")", "", 1, -1, 1)

                'Check the file size is not above the max allowed size, this is done using a function not the compoent to stop an exception error
                lngErrorFileSize = fileSize(.Files(1).Size, intMaxFileSize)

                'Loop through all the allowed extensions and see if the file has one
                blnExtensionOK = fileExtension(strNewFileName, saryFileUploadTypes)

                'If the file is OK save it to disk
                If lngErrorFileSize = 0 AND blnExtensionOK = True Then

                    '** AspUpload does have a function to stop files form being over written but this can allow the forum open to malicious code **
                    '** so instead if the file exists create an acceptable new name for the file **
                    'Check to make sure the file does not already exist
                    Do While .FileExists(Server.MapPath(strFileUploadPath) & "\" & strNewFileName)

                        'Create a new file name for the file if it already exsist
                        strNewFileName = hexValue(3) & "_" & strNewFileName
                    Loop
                   

                    'Save the file to disk with new file name
                    '** Copy virtual is used as save as is often disabled by the web host **
                    .Files(1).CopyVirtual strFileUploadPath & "/" & strNewFileName

                    'As a new copy of the file is saved we need to get rid of the old copy
                    .Files(1).Delete

                    'Pass the filename back
                    fileUpload = strNewFileName


                'Else if it is not OK delete the uploaded file
                Else
                    .Files(1).Delete

                End If

            End With

            'Clean up
            Set objUpload = Nothing
Avatar billede olebole Juniormester
16. april 2004 - 12:47 #3
<ole>

Hvorfor skriver du ikke hvilke fejl, du får? Det ville nok hjælpe væsentligt på mulighederne for hjælp  ;o)

/mvh
</bole>
Avatar billede kometen79 Nybegynder
29. april 2004 - 09:53 #4
lukker
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
Vi tilbyder markedets bedste kurser inden for webudvikling

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

Seneste spørgsmål Seneste aktivitet
I går 10:21 Ny printer, men hvilken Af mort1 i Printere
13/0819:41 USB på Linux Af Uvanga i Linux
12/0818:26 Hvilken type mus Af mort1 i PC
11/0813:21 ms Forms Af leahcim i Andet software
10/0821:30 Blokeret på Snapchat? Af LineP i Chat & Messaging