When uploading an image I get the error:
Notice: Undefined index: image in C: \ Apache24 \ htdocs \ change_photo.php on line 9
Notice: Undefined index: image in C: \ Apache24 \ htdocs \ change_photo.php on line 10
Call:
<script type="text/javascript">
$(document).ready(function(){
$('#imagem').live('change',function(){
var url1 = "change_photo.php";
var email1 = "<?php echo $_SESSION['email']?>";
var fileVal=document.getElementById("imagem");
var fakeFile = fileVal.value;
$.post(url1,{postemail1:email1,foto:fakeFile},
function(result) {
$("#visualizar").html(result); // Só pra verificar retorno
});
});
})
</script>
Form:
<form id="formulario" method="post" enctype="multipart/form-data" action="change_photo.php">
Foto
<input type="file" id="imagem" name="imagem" />
</form>
Change_photo.php:
include('conexao.php');
$pasta = "fotos/";
/* formatos de imagem permitidos */
echo $_POST['foto'];
$permitidos = array(".jpg",".jpeg",".gif",".png", ".bmp");
$name = $_FILES['imagem']['name'];
$tmp_name = $_FILES['imagem']['tmp_name'];
$error = $_FILES['imagem']['error'];
Could anyone tell me where the problem is?