Usamos cookies para medir audiência e melhorar sua experiência. Você pode aceitar ou recusar a qualquer momento. Veja sobre o iMasters.
Estou com um cadastro de alunos. Onde tem opção de inserir foto, sendo que só faz isso depois que ele faz seu cadastro normal, no caso ele cadastrado, tem a opção de incluir a foto. Quando vou incluir a foto da um erro mais mesmo assim cadastra. Tem também abaixo dos dados deles a exibição de todos os cadastrados, onde queria incluir a foto deles tb na exibição.
Vou postar aqui primeiro a parte do cadastro, onde inclui a foto e dá erro.
INICIO
<?php
require("configuracao_alunos.php");
session_start();
require("verifica.php");
$idexaluno = $_GET[idexaluno];
?>
FORM DO ENVIO DE FOTO
<form action="insere_foto-exaluno.php" method="post" enctype="multipart/form-data" name="formulario" id="formulario">
<table width="526" height="94" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="90" height="24" align="right">Arquivo:</td>
<td width="18" align="right"> </td>
<td colspan="2"><input name="foto" type="file" class="textfield" size="50"/>
<input type="hidden" id="idexaluno" name="idexaluno" value="<?php echo $idexaluno; ?>" /></td>
</tr>
<tr>
<td height="24" align="right"> </td>
<td align="center"><label></label></td>
<td width="161"><label>
<input name="cadastrar" type="submit" class="textfield" id="cadastrar" value="Cadastrar" />
</label></td>
<td width="257"><input name="Reset" type="reset" class="textfield" value="Limpar" /></td>
</tr>
<tr>
<td height="13" colspan="4" align="right"> </td>
</tr>
</table>
</form>
PHP DO ENVIO DE FOTO
<?php
$sql2 = mysql_query("SELECT substring(foto,16) as nome FROM exalunofoto WHERE idexaluno='$idexaluno' ORDER BY idfotoexaluno DESC");
echo "<img src='fotos-exalunos/".$listafotos['nome']."' id='cropbox' />";
echo "<div style='width:100px;height:100px;overflow:hidden;'>";
echo "<img src='fotos-exalunos/".$listafotos['nome']."' id='preview' />";
echo "</div>";
//}
?>
O ARQUIVO CHAMA OUTRO ARQUIVO DE ENVIO
insere_foto-exaluno.php
<?php
header("Content-type: text/html; charset=ISO-8859-1", true);
require("configuracao_alunos.php");
session_start();
require("verifica.php");
//se existir o arquivo
if(isset($_FILES["foto"])){
$foto = $_FILES["foto"];
$idexaluno = $_POST["idexaluno"];
$pasta_dir = "fotos-exalunos/";//diretorio dos arquivos
//se não existir a pasta ele cria uma
if(!file_exists($pasta_dir)){
mkdir($pasta_dir);
}
$arquivo_nome = $pasta_dir . $foto["name"];
// Faz o upload da imagem
move_uploaded_file($foto["tmp_name"], $arquivo_nome);
//aqui salva no banco o path da foto
$cadcaminho = "INSERT INTO exalunofoto (foto, idexaluno) VALUES ('$arquivo_nome', '$idexaluno')";
$result = mysql_query($cadcaminho);
if(!$result){
header("Location: http://www.google.com.br");
} else {
header("Location: cadastra_foto-exaluno.php");
}
}
?>
COMO FALEI ELE CADASTRA MAIS APRESENTA O ERRO ABAIXO:
Warning: move_uploaded_file(fotos-exalunos/dna.jpg) [function.move-uploaded-file]: failed to open stream: Permission denied in /home/cscj-pi/www/cscj/exalunos/insere_foto-exaluno.php on line 22
Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move '/tmp/phpWdeO4W' to 'fotos-exalunos/dna.jpg' in /home/cscj-pi/www/cscj/exalunos/insere_foto-exaluno.php on line 22
Warning: Cannot modify header information - headers already sent by (output started at /home/cscj-pi/www/cscj/exalunos/insere_foto-exaluno.php:22) in /home/cscj-pi/www/cscj/exalunos/insere_foto-exaluno.php on line 33
Carregando comentários...