manuel dias Posted July 21, 2012 at 12:51 PM Report Share #469504 Posted July 21, 2012 at 12:51 PM (edited) <html> <head> <title>Script de Fotos</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <link href="/includes/estilos/azul.css" rel="stylesheet" type="text/css"> <style type="text/css"> <!-- .style4 { color: #FF0000; font-weight: bold; font-size: 10px; } .style5 {font-size: 10px} --> </style> <script> var escondido = 0; function preview() { img = document.getElementById('img'); if(escondido) { esc.innerHTML = '<a href="javascript:;" class="menu style5" onclick="preview()">(esconder)</a><br><img onload="getSize()" width="150" src="'+escondido+'" name="img" id="img">'; escondido = 0; } else { escondido = img.src; img.src = ''; esc.innerHTML = '<a href="javascript:;" class="menu style5" onclick="preview()">(mostrar)</a><br><img onload="getSize()" src="1px.gif" width="1" height="1" name="img" id="img">'; } } function find_array(arr,str) { for(i=0; arr.length>i; i++) { if(arr[i] == str) return 1; } return 0; } function verificaFoto() { var obj = document.getElementById('file'); var v = obj.value; var extencao=v.substr(v.length - 4).toLowerCase(); var extPerm = new Array(".gif",".jpg",".png","jpeg",".GIF",".JPG",".PNG","JPEG"); var img = document.getElementById('img'); img.src = "file://"+obj.value; img.width = 200; if(!find_array(extPerm,extencao)) { alert("Só são permitidas fotos nos formatos GIF, PNG e JPG/JPEG"); obj.value = ""; esc.innerHTML = '<br><img onload="getSize()" src="1px.gif" width="1" height="1" name="img" id="img">'; return 0; } escondido = img.src; if(escondido) preview(); } function getSize() { if(document.getElementById('img').fileSize > 200000) { alert("A foto não pode ter mais de 200 KB."); obj.value = ""; esc.innerHTML = '<br><img onload="getSize()" src="1px.gif" width="1" height="1" name="img" id="img">'; return 0; } return 1; } var escondido1 = 0; function preview1() { img1 = document.getElementById('img1'); if(escondido1) { esc1.innerHTML = '<a href="javascript:;" class="menu style5" onclick="preview1()">(esconder)</a><br><img onload="getSize1()" width="150" src="'+escondido1+'" name="img1" id="img1">'; escondido1 = 0; } else { escondido1 = img1.src; img1.src = ''; esc1.innerHTML = '<a href="javascript:;" class="menu style5" onclick="preview1()">(mostrar)</a><br><img1 onload="getSize1()" src="1px.gif" width="1" height="1" name="img1" id="img1">'; } } function find_array1(arr,str) { for(i=0; arr.length>i; i++) { if(arr[i] == str) return 1; } return 0; } </script> <script language="JavaScript"> <!-- function MM_reloadPage(init) { //reloads the window if Nav4 resized if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) { document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }} else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload(); } MM_reloadPage(true); // --> </script> <FORM METHOD="POST" ACTION="" name="sistema"> </head> <body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" bgcolor="#FFFFFF" text="#000000" link="#000000" vlink="#000000" alink="#666666"> <div id="Layer1" style="position:absolute; left:40%; top:-350px; width:300px; height:150px; z-index:1"> <table width="300" border="0" cellpadding="0" cellspacing="0" class="tabelaborda"> <tr> <td height="20" colspan="3" class="tabelatopo"><font face="Tahoma" size="1"> AGUARDE...</font></td> </tr> <tr> <td height="10" colspan="3"><font face="Tahoma" size="1"><img src="1px.gif" width="1" height="1"></font></td> </tr> <tr> <td width="10" rowspan="2"> </td> <td width="280" align="center" valign="middle" class="verdana12"> <div align="justify"><font face="Tahoma" size="1">Aguarde enquanto a foto está sendo enviada. Isto pode levar alguns segundos. <strong>Não pare este processo.</strong> </font></div> <td width="10" rowspan="2"> </td> </tr> <tr> <td height="12" colspan="3" class="noticialink"><font face="Tahoma" size="1"><img src="1px.gif" width="1" height="1"></font></td> </tr> </table> </div> <hr size="1"> <table width="212" border="1"> <tr> <td width="510"><table width="204" border="0" cellpadding="0" cellspacing="5"> <input type="hidden" name="MAX_FILE_SIZE" value="1048576" /> <tr> <td valign="top"><p class="texto"><b><font face="Tahoma" size="1">FOTO 1 :<br> <input type="file" id="file" onChange="verificaFoto()" name="file" size="20" /> </font></b></p></td> </tr> <tr> <td valign="top" class="texto"><font face="Tahoma" size="1">Pré-visualização: <label id="esc"><br> <img src="1px.GIF" name="img" id="img" width="1" height="1"></label> </font></td> </tr> </table></td> </tr> </table> </form> </body> </html> Edited July 21, 2012 at 01:09 PM by anolsi Adicionado o geshi Link to comment Share on other sites More sharing options...
pmg Posted July 21, 2012 at 12:54 PM Report Share #469505 Posted July 21, 2012 at 12:54 PM Mete o teu codigo num bloco de codigo: [ code=html4strict ] ... [ /code ] E faz uma pergunta ou comentario especifico 🙂 What have you tried? Não respondo a dúvidas por PM A minha bola de cristal está para compor; deve ficar pronta para a semana. Torna os teus tópicos mais atractivos e legíveis usando a tag CODE para colorir o código! Link to comment Share on other sites More sharing options...
manuel dias Posted July 21, 2012 at 12:57 PM Author Report Share #469506 Posted July 21, 2012 at 12:57 PM (edited) é a 2ª vez que estou a utilizar osite e na barra de ferramentas do editor avançado não tenho um botão contendo o símbolo "< >" de forma a por isto em blocos. Com o codigo acima em HTML consigo verificar a imagem quando faço o upload, mas ao gravar em php a imagem não aparece. Alguèm me consegue ajudar? Edited July 21, 2012 at 01:18 PM by manuel dias Link to comment Share on other sites More sharing options...
HappyHippyHippo Posted July 21, 2012 at 01:27 PM Report Share #469512 Posted July 21, 2012 at 01:27 PM não te estás a esquecer de umas pequenas coisas : - o código php que recebe o ficheiro - como sabes que mas ao gravar em php a imagem não aparece. Alguèm me consegue ajudar? IRC : sim, é algo que ainda existe >> #p@p Portugol Plus Link to comment Share on other sites More sharing options...
manuel dias Posted July 21, 2012 at 03:27 PM Author Report Share #469530 Posted July 21, 2012 at 03:27 PM <?php if($_FILES["file"] != “”){ $arquivo = $_FILES['file']; move_uploaded_file($arquivo['tmp_name'], "upload/".$arquivo['name']); } ?> [ Tentei introduzir este código, mas não funcionou, os meus conhecimentos são fracos. Link to comment Share on other sites More sharing options...
HappyHippyHippo Posted July 21, 2012 at 04:52 PM Report Share #469538 Posted July 21, 2012 at 04:52 PM os teus conhecimentos são fracos é de HTML <FORM METHOD="POST" ACTION="" name="sistema"> não te falta nada : http://www.tizag.com/phpT/fileupload.php/ IRC : sim, é algo que ainda existe >> #p@p Portugol Plus Link to comment Share on other sites More sharing options...
manuel dias Posted July 21, 2012 at 07:11 PM Author Report Share #469555 Posted July 21, 2012 at 07:11 PM (edited) <form enctype="multipart/form-data" action="uploader.php" method="POST"> <input type="hidden" name="MAX_FILE_SIZE" value="100000" /> Choose a file to upload: <input name="uploadedfile" type="file" /><br /> <input type="submit" value="Upload File" /> </form> <?php $TARGET_PATH = "Users/madias/Downloads"; $Caminho_destino = $TARGET_PATH. basename ($_FILES ['uploadedfile'] ['name']); if (move_uploaded_file ($_FILES ['uploadedfile'] ['tmp_name'], $TARGET_PATH)) { echo "O arquivo". basename ($_FILES ['uploadedfile'] ['name']). "Foi enviado"; }Else { echo "Ocorreu um erro ao fazer o upload do arquivo, por favor, tente novamente!"; } ?> Segui o exemplo o resultado foi: "Ocorreu um erro ao fazer o upload do arquivo, por favor, tente novamente!" Não consigo perceber onde estou a falhar.... Edited July 21, 2012 at 07:14 PM by manuel dias Link to comment Share on other sites More sharing options...
HappyHippyHippo Posted July 21, 2012 at 07:22 PM Report Share #469559 Posted July 21, 2012 at 07:22 PM verifica estas duas situações: - o diretório onde estás a gravar o ficheiro existe - tens permissões de gravar o ficheiro no diretorio IRC : sim, é algo que ainda existe >> #p@p Portugol Plus Link to comment Share on other sites More sharing options...
manuel dias Posted July 21, 2012 at 07:32 PM Author Report Share #469562 Posted July 21, 2012 at 07:32 PM estou a utilizar o xampp, o directório poderá ser uma pasta dentro da pasta "htdocs"? Link to comment Share on other sites More sharing options...
joaocasta Posted July 21, 2012 at 08:03 PM Report Share #469573 Posted July 21, 2012 at 08:03 PM Sim, terás de ter isto definido dentro da pasta htdocs "Users/madias/Downloads"... Link to comment Share on other sites More sharing options...
MoshMage Posted July 22, 2012 at 02:13 PM Report Share #469645 Posted July 22, 2012 at 02:13 PM (edited) <FORM METHOD="POST" ACTION="" name="sistema"> </head> <body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" bgcolor="#FFFFFF" text="#000000" link="#000000" vlink="#000000" alink="#666666"> </head> <body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" bgcolor="#FFFFFF" text="#000000" link="#000000" vlink="#000000" alink="#666666"> <FORM METHOD="POST" ACTION="" name="sistema"> assim?! *edited: reformat do texto Edited July 22, 2012 at 02:16 PM by MoshMage If all Else fails, use Else If; Link to comment Share on other sites More sharing options...
manuel dias Posted July 22, 2012 at 04:36 PM Author Report Share #469650 Posted July 22, 2012 at 04:36 PM Também não dá. Link to comment Share on other sites More sharing options...
yoda Posted July 22, 2012 at 09:06 PM Report Share #469676 Posted July 22, 2012 at 09:06 PM Usa caminhos absolutos e não relativos. Em último caso trabalha sob as pastas dentro do htdocs, que corresponde à raiz do webserver. before you post, what have you tried? - http://filipematias.info sense, purpose, direction Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now