I need to upload the image with ajax / jquery, following this structure:
Form:
<form>
<input type="text" name="seu_nome" />
<input type="text" name="sua_senha" />
<input type="file" name="file" />
<button type="submit">Enviar</button>
</form>
Ajax / Jquery:
$("#form_"+screen_label).submit(function(){
var dados = $( this ).serialize();
$.ajax({
type: "POST",
url: "upload.php",
data: dados,
success: function( data ){
//ok
}//end success
});//end method
/* .............................................. */
return false;
});//end submit
o php:
if (isset($_FILES['file']) && !empty($_FILES['file']['name'])) {
$file_name = $_FILES['file']['name'];
$file_type = $_FILES['file']['type'];
$file_size = $_FILES['file']['size'];
$file_tmp_name = $_FILES['file']['tmp_name'];
$error = $_FILES['file']['error'];
//echo $file_name;
//echo $titulo;
/*
switch($file_type){
case 'image/png': $arq ='.png';break;
case 'image/jpeg': $arq ='.jpg';break;
case 'image/gif': $arq ='.gif';break;
case 'image/bmp': $arq ='.bmp';break;
case 'image/PNG': $arq ='.PNG';break;
case 'image/JPEG': $arq ='.JPEG';break;
case 'image/GIF': $arq ='.GIF';break;
case 'image/BMP': $arq ='.BMP';break;
}
*/
$destino = 'imgs/';
move_uploaded_file($file_tmp_name,$destino.$file_name);
}//end if isset file
Does anyone know what's missing for the upload to happen and the image to be saved in the folder?