1
When uploading an image I get the error:
Notice: Undefined index: imagem in C: Apache24 htdocs change_photo.php on line 9
Notice: Undefined index: imagem in C: Apache24 htdocs change_photo.php on line 10
Calling for:
<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'];
Would anyone know where the problem is?
need to be uploaded using jquery? the error I believe you are making this
$.post
via jquery. Just try with php and html– Mastria