Ir para conteúdo
Fórum Script Brasil
  • 0

Editor Texto ACE / Upload Imagens


Cassius Andrade

Pergunta

Olá turma..

Bem, estou utilizando o Editor de Texto Advanced Content Editor da Yusuf Wiryonoputro.

Nele tem a opção de inserir imagem naquele esqueminha de upload.

Eles estava dando um erro de caminho, detectei que o caminho fica numa global.asa

a dúvida é saber se alguém já utilizou ou se alguém sabe e pode me ajudar com esse caminho.

o código onde é chamado é esse abaixo..

<%
imgFolder = Application("PastaImagens") 'Locate your image folder here

if Request.QueryString("action")="del" then
    filepath = request.QueryString("file")
    Set objFSO1 = Server.CreateObject("Scripting.FileSystemObject")
    Set MyFile = objFSO1.GetFile(Server.MapPath(filepath))
    MyFile.Delete
    Response.Redirect "default_Image.asp?catid="& request.QueryString("catid")
end if

if Request.QueryString("action")="upload" then
    Response.Expires = 0
    Response.Buffer = TRUE
    Response.Clear

    Dim UploadRequest
    Set UploadRequest = CreateObject("Scripting.Dictionary")

    ByteCount = Request.TotalBytes
    RequestBin = Request.BinaryRead(byteCount)
    BuildUploadRequest  RequestBin


    Dim aux, aux1, FILEFLAG

    Dim ImageCateg, ContentType, FilePathName, FileName, Value
    ImageCateg=UploadRequest.Item("inpcatid").Item("Value")'Image Folder

    on error resume next
    ContentType =UploadRequest.Item("inpFile").Item("ContentType")
    FILEFLAG = err.number
    on error goto 0

    if FILEFLAG = 0 then
            ContentType = UploadRequest.Item("inpFile").Item("ContentType")
            FilePathName = UploadRequest.Item("inpFile").Item("FileName")
            FileName = Right(filepathname,Len(filepathname)-InstrRev(filepathname,"\"))
            Value = UploadRequest.Item("inpFile").Item("Value")
    else
            FileName = ""
    end if

    if FileName<>"" then 
            Set objFSO2 = Server.CreateObject("Scripting.FileSystemObject")
            Set MyFile = objFSO2.CreateTextFile(ImageCateg&"\"&FileName)
            MyFile.Write getString(value)
            MyFile.Close
    end if

    set UploadRequest = nothing
    
    Response.Redirect "default_Image.asp?catid="&ImageCateg
End If
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
%>
<html>
<head>
    <title>Inserir/Alterar Imagem</title>
    <style>
    form {
        margin: 0px;
    }
    TABLE
        {
        FONT-SIZE: 10;
        FONT-FAMILY: Verdana
    }
    .bar 
        {
        BORDER-TOP: #99ccff 1px solid; BACKGROUND: #336699; WIDTH: 100%; BORDER-BOTTOM: #000000 1px solid; HEIGHT: 20px
    }        
    .texto {font-size: 10px}
    </style>
    <link href="includes/estilo.css" rel="stylesheet" type="text/css">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><style type="text/css">
<!--
body,td,th {
    font-size: 10px;
}
-->
</style></head>
<%
dim objFSO
dim objMainFolder

dim strOptions
dim strHTML
dim catid

strHTML = ""

set objFSO = server.CreateObject ("Scripting.FileSystemObject")
set objMainFolder = objFSO.GetFolder(server.MapPath(imgFolder))
         
catid = CStr(request("catid"))'bisa form, bisa querystring
if catid="" then catid = objMainFolder.path



dim objTempFSO
dim objTempFolder
dim objTempFiles
dim objTempFile

set objTempFSO = server.CreateObject ("Scripting.FileSystemObject")
set objTempFolder = objTempFSO.GetFolder (catid)
set objTempFiles = objTempFolder.files

strHTML = strHTML & "<table border=0 cellpadding=0 cellspacing=0 width='100%'>"
for each objTempFile in objTempFiles

    '***********
    'objTempFile.path => image physical path
    'basePath => base path
    set basePath = objFSO.GetFolder(server.MapPath(imgFolder))
    PhysicalPathWithoutBase = Replace(objTempFile.path,basePath.path,"")    
    sTmp = replace(PhysicalPathWithoutBase,"\","/")'fix from physical to virtual
    sCurrImgPath = Application("Caminho") & imgFolder & sTmp
    '***********

    strHTML = strHTML & "<tr bgcolor=#D7D7D7 height=20>"
    strHTML = strHTML & "<td valign=middle width=8>&nbsp;</td>"
    strHTML = strHTML & "<td valign=middle width=180>" & objTempFile.name & "</td>"
    'strHTML = strHTML & "<td valign=top>" & objTempFile.type & "</td>"
    strHTML = strHTML & "<td valign=middle width=50>" & FormatNumber(objTempFile.size/1000,0) & " kb</td>"
    strHTML = strHTML & "<td valign=middle width=20><center><font color='#666666'><img src='imagens/ofile.gif' alt='Selecionar Arquivo' align='absmiddle' onclick=""selectImage('" & sCurrImgPath  & "')"" style=""cursor:hand;""></font></center></td>"
    'strHTML = strHTML & "<td valign=middle><div align=left><font color='#666666'><img src='imagens/del.gif' alt='Deletar Arquivo' align='absmiddle' onclick=""deleteImage('" & sCurrImgPath & "')"" style=""cursor:hand;""></font></div></td>"
    strHTML = strHTML & "</tr>"
    strHTML = strHTML & "<tr height='1'><td><img src='imagens/transp.gif' width=1 height=1></td></tr>"

next
strHTML = strHTML & "</table>"

Function createCategoryOptions(pi_objFolder)
    dim objFolder
    dim objFolders
    
    set objFolders = pi_objfolder.SubFolders
    for each objFolder in objFolders 
        'Recursive programming starts here
        createCategoryOptions objFolder
    next
    
    if pi_objFolder.attributes and 2 then
        'hidden folder then do nothing
    else    

'***********
set basePath = objFSO.GetFolder(server.MapPath(imgFolder))
'response.Write catid & " - " & oo.path
Response.Write Replace(pi_objFolder.path,basePath.path,"")    
'***********
    
        if CStr(catid)=CStr(pi_objFolder.path) then
            strOptions = strOptions & "<option value=""" & pi_objFolder.path & """ selected>" & Replace(pi_objFolder.path,basePath.path,"")     & "</option>" & vbCrLf
        else
            strOptions = strOptions & "<option value=""" & pi_objFolder.path & """>" & Replace(pi_objFolder.path,basePath.path,"")      & "</option>" & vbCrLf
        end if
    end if
    
    strOptions = strOptions & vbCrLf
    createCategoryOptions = strOptions
End Function

function ConstructPath(str)
    str  = mid(str,len(server.MapPath ("./"))+1)
    ConstructPath = replace(str,"\","/")
end function
%>
<body onLoad="checkImage()" link=Blue vlink=MediumSlateBlue alink=MediumSlateBlue background='imagens/cor_fundo_cinza_claro.jpg'>



    <table width="600" border="0" cellpadding="0" cellspacing="0">
    <tr>
    <td valign=top>
        <!-- Content -->

        <table width="100%" border=0 align=center cellpadding=0 cellspacing=0>
        <tr>
          <td height="10" colspan="5" align=center><img src="imagens/transp.gif" width="1" height="1"></td>
          </tr>
        <tr>
          <td width="10" align=center>&nbsp;</td>
          <td width="250" align=center valign="top"><table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">
            <tr>
              <td width="7" height="7"><img src="imagens/quadro_canto_sup_esq.jpg" width="7" height="7"></td>
              <td height="7" background="imagens/quadro_lado_sup.jpg"><img src="imagens/transp.gif" width="1" height="1"></td>
              <td width="7" height="7"><img src="imagens/quadro_canto_sup_dir.jpg" width="7" height="7"></td>
            </tr>
            <tr>
              <td width="7" background="imagens/quadro_lado_esq.jpg">&nbsp;</td>
              <td height="200" align="center" valign="middle" bgcolor="#FFFFFF"><div id="divImg" style="overflow:auto;width:250;height:150" align="center" >
              </div></td>
              <td width="7" background="imagens/quadro_lado_dir.jpg">&nbsp;</td>
            </tr>
            <tr>
              <td width="7" height="7"><img src="imagens/quadro_canto_inf_esq.jpg" width="7" height="7"></td>
              <td height="7" background="imagens/quadro_lado_inf.jpg"><img src="imagens/transp.gif" width="1" height="1"></td>
              <td width="7" height="7"><img src="imagens/quadro_canto_inf_dir.jpg" width="7" height="7"></td>
            </tr>
          </table></td>
          <td width="10" valign=top>&nbsp;</td>
          <td width="320" height="25" valign=top>
                <form method=post action=<%=Request.ServerVariables("SCRIPT_NAME")%> id=form2 name=form2>
                        <table width="100%" height=20 border=0 cellpadding=0 cellspacing=0><tr valign="middle">
                        <td width="150"><span class="texto"><b><img src="imagens/cfolder.gif" width="20" height="20" align="absmiddle">&nbsp;Selecione a Pasta &nbsp;:</b></span><b>&nbsp;</b></td>
                        <td>
                        <select name=catid class="campos" id=catid onChange="form2.submit()">
                        <%=createCategoryOptions(objMainFolder)%>
                        </select> 
                        </td></tr>
                        </table></form>
                <table width='100%' border=0 cellpadding=0 cellspacing=0>
                <tr>
                  <td height="10"><img src="imagens/transp.gif" width="1" height="1"></td>
                  </tr>
                <tr><td height="20" bgcolor="#B4B4B4">
                <div class="texto" style="padding-left: 5px; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 10px; color: #FFFFFF;">
                  <b>Sele&ccedil;&atilde;o de Arquivo: </b>
                </div>
                </td>
                </tr>
            </table>
            <div style="overflow:auto;height:163;width:100%;BORDER-LEFT: #B4B4B4 1px solid;BORDER-RIGHT: #B4B4B4 1px solid;BORDER-BOTTOM: #B4B4B4 1px solid;">
                <%=strHTML%>
            </div>          </td>                        
          <td width="8" valign=top>&nbsp;</td>
        </tr>
        <tr>
          <td height="4" colspan=5><img src="imagens/transp.gif" width="1" height="1"></td>
          </tr>
        <tr>
          <td colspan=5><hr size="1" color="#999999"></td>
          </tr>
        <tr>
          <td colspan=5><FORM METHOD="Post" ENCTYPE="multipart/form-data" ACTION="default_Image.asp?action=upload" ID="form1" name="form1">
              <table width="100%" height="19" border="0" cellpadding="0" cellspacing="0">
                <tr>
                  <td width="10">&nbsp;</td>
                  <td width="120"><span class="texto"><img src="imagens/upload.gif" width="27" height="26" align="absmiddle">&nbsp;&nbsp;Upload  :</span></td>
                  <td>
                    <INPUT name=inpFile type="file" style='height: 18px; width: auto; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 10px; color: #000000; text-decoration: none; border: 1px solid #999999;' id="inpFile" size="60">
                    <input name="inpcatid" ID="inpcatid" type=hidden>
&nbsp;
<INPUT name="button" TYPE="button" class="botao_upload"  onclick="inpcatid.value=form2.catid.value;form1.submit()" value="Upload"></td>
                </tr>
              </table>
          </FORM></td>
          </tr>
        <tr>
        <td colspan=5>
                
                <hr size="1" color="#999999">    
                <table border=0 width=100% cellpadding=0 cellspacing=0>
                <tr>
                  <td width="10" rowspan="5" class="texto">&nbsp;</td>
                        <td width="120" height="22" class="texto">Arquivo : </td>
                        <td height="22" colspan=3>
                        <INPUT name=inpImgURL type="text" class="campos" id="inpImgURL" size=60>
                  <!--<font color=red>(you can type your own image path here)</font>-->                  </td>        
                </tr>                    
                <tr>
                  <td width="120" height="22" class="texto">Texto Alternativo  : </td>
                        <td height="22" colspan=3><INPUT name=inpImgAlt type="text" class="campos" id="inpImgAlt" size=60></td>        
                </tr>                
                <tr>
                  <td width="120" height="22" class="texto">Alinhamento : </td>
                        <td width="80" height="22">
                        <select NAME="inpImgAlign" class="campos" ID="inpImgAlign">
                                <option value="">&lt;N&atilde;o Informado&gt;</option>
                                <option value="absBottom">absBottom</option>
                                <option value="absMiddle">absMiddle</option>
                                <option value="baseline">baseline</option>
                                <option value="bottom">bottom</option>
                                <option value="left">left</option>
                                <option value="middle">middle</option>
                                <option value="right">right</option>
                                <option value="textTop">textTop</option>
                                <option value="top">top</option>                        
                        </select>                  </td>
                        <td width="120" height="22" class="texto">Tamanho Borda :</td>
                        <td width="100" height="22"><INPUT NAME="inpImgBorder" type="text" class="campos" ID="inpHSpace3" size=5>                        </td>                    
                </tr>
                <tr>
                  <td width="120" height="22" class="texto">Comprimento :</td>
                  <td width="80" height="22"><INPUT NAME="inpImgWidth" type="text" class="campos" ID="inpImgWidth" size=5></td>
                        <td width="120" height="22" class="texto">Espa&ccedil;o Horizontal  :</td>
                  <td width="100" height="22"><INPUT NAME="inpHSpace" type="text" class="campos" ID="inpHSpace" size=5></td>
                </tr>                
                <tr>
                  <td width="120" height="22" class="texto">Altura :</td>
                  <td width="80" height="22"><INPUT NAME="inpImgHeight" type="text" class="campos" ID="inpImgHeight" size=5></td>
                        <td width="120" height="22" class="texto">Espa&ccedil;o Vertical :</td>
                  <td width="100" height="22"><INPUT NAME="inpVSpace" type="text" class="campos" ID="inpVSpace" size=5></td>
                </tr>
                <tr>
                  <td height="8" colspan="5" class="texto"><img src="imagens/transp.gif" width="1" height="1"></td>
                  </tr>
            </table>

        </td>
        </tr>
        <tr>
        <td height="40" colspan=5 align=center>
                <table width="100" align=center cellpadding=0 cellspacing=0><tr>
                <td><INPUT type="button" style='height: 18px; width: auto; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 10px; color: #000000; text-decoration: none; border: 1px solid #999999;' value="Cancelar" onClick="self.close();" ID="Button1" NAME="Button1"></td>
                <td width="30">&nbsp;&nbsp;&nbsp;&nbsp;</td>
                <td>
                <span id="btnImgInsert" style="display:none">
                <INPUT type="button" value="Inserir" onClick="InsertImage();self.close();" style='height: 18px; width: auto; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 10px; color: #000000; text-decoration: none; border: 1px solid #999999;' ID="Button2" NAME="Button2">
                </span>
                <span id="btnImgUpdate" style="display:none">
                <INPUT type="button" value="Alterar" onClick="UpdateImage();self.close();" style='height: 18px; width: auto; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 10px; color: #000000; text-decoration: none; border: 1px solid #999999;' ID="Button3" NAME="Button3">
                </span>                
                </td>
                </tr></table>        </td>
        </tr>
      </table>        </td>
    </tr>
</table>



<script language="JavaScript">
function deleteImage(sURL)
    {
    if (confirm("Tem certeza que quer\ndeletar este aquivo?") == true) 
        {
        window.navigate("default_Image.asp?action=del&file="+sURL+"&catid="+form2.catid.value);
        }
    }
function selectImage(sURL)
    {
    inpImgURL.value = sURL;
    
    divImg.style.visibility = "hidden"
    divImg.innerHTML = "<img id='idImg' src='" + sURL + "'>";
    

    var width = idImg.width
    var height = idImg.height 
    var resizedWidth = 150;
    var resizedHeight = 170;

    var Ratio1 = resizedWidth/resizedHeight;
    var Ratio2 = width/height;

    if(Ratio2 > Ratio1)
        {
        if(width*1>resizedWidth*1)
            idImg.width=resizedWidth;
        else
            idImg.width=width;
        }
    else
        {
        if(height*1>resizedHeight*1)
            idImg.height=resizedHeight;
        else
            idImg.height=height;
        }
    
    divImg.style.visibility = "visible"
    }

/***************************************************
    If you'd like to use your own Image Library :
    - use InsertImage() method to insert image
        Params : url,alt,align,border,width,height,hspace,vspace
    - use UpdateImage() method to update image
        Params : url,alt,align,border,width,height,hspace,vspace
    - use these methods to get selected image properties :
        imgSrc()
        imgAlt()
        imgAlign()
        imgBorder()
        imgWidth()
        imgHeight()
        imgHspace()
        imgVspace()
        
    Sample uses :
        window.opener.obj1.InsertImage(...[params]...)
        window.opener.obj1.UpdateImage(...[params]...)
        inpImgURL.value = window.opener.obj1.imgSrc()
    
    Note: obj1 is the editor object.
    We use window.opener since we access the object from the new opened window.
    If we implement more than 1 editor, we need to get first the current 
    active editor. This can be done using :
    
        oName=window.opener.oUtil.oName // return "obj1" (for example)
        obj = eval("window.opener."+oName) //get the editor object
        
    then we can use :
        obj.InsertImage(...[params]...)
        obj.UpdateImage(...[params]...)
        inpImgURL.value = obj.imgSrc()
        
***************************************************/    
function checkImage()
    {
    oName=window.opener.oUtil.oName
    obj = eval("window.opener."+oName)
    
    if (obj.imgSrc()!="") selectImage(obj.imgSrc())//preview image
    inpImgURL.value = obj.imgSrc()
    inpImgAlt.value = obj.imgAlt()
    inpImgAlign.value = obj.imgAlign()
    inpImgBorder.value = obj.imgBorder()
    inpImgWidth.value = obj.imgWidth()
    inpImgHeight.value = obj.imgHeight()
    inpHSpace.value = obj.imgHspace()
    inpVSpace.value = obj.imgVspace()

    if (obj.imgSrc()!="") //If image is selected 
        btnImgUpdate.style.display="block";
    else
        btnImgInsert.style.display="block";
    }
function UpdateImage()
    {
    oName=window.opener.oUtil.oName
    eval("window.opener."+oName).UpdateImage(inpImgURL.value,inpImgAlt.value,inpImgAlign.value,inpImgBorder.value,inpImgWidth.value,inpImgHeight.value,inpHSpace.value,inpVSpace.value);    
    }
function InsertImage()
    {
    oName=window.opener.oUtil.oName
    eval("window.opener."+oName).InsertImage(inpImgURL.value,inpImgAlt.value,inpImgAlign.value,inpImgBorder.value,inpImgWidth.value,inpImgHeight.value,inpHSpace.value,inpVSpace.value);
    }    
/***************************************************/
</script>
</body>
</html>
aqui é o global .asa
Sub Application_OnStart 
        
    REM Configuração dos e-mails do site
    Application("Registro_Pagina_Admin") = 30
    Application("PastaImagens") = "imagens_up"
    Application("PastaMultimidia") = "multimidia"
    Application("Caminho") = "http://met/crcbusca/admin/"

End Sub

a pasta onde é para ser salva é essa imagens_up e ela está na raiz do admin.

gostaria de saber o caminho se coloco virtual ou físico?

um abraço...

Cassius

Link para o comentário
Compartilhar em outros sites

0 respostass a esta questão

Posts Recomendados

Até agora não há respostas para essa pergunta

Participe da discussão

Você pode postar agora e se registrar depois. Se você já tem uma conta, acesse agora para postar com sua conta.

Visitante
Responder esta pergunta...

×   Você colou conteúdo com formatação.   Remover formatação

  Apenas 75 emoticons são permitidos.

×   Seu link foi incorporado automaticamente.   Exibir como um link em vez disso

×   Seu conteúdo anterior foi restaurado.   Limpar Editor

×   Você não pode colar imagens diretamente. Carregar ou inserir imagens do URL.



  • Estatísticas dos Fóruns

    • Tópicos
      152,3k
    • Posts
      652,3k
×
×
  • Criar Novo...