I got some wired problem while posting a form using jquery ajax. i have a multiple image upload field. while i use e.preventDefault() function the images aren't uploading. but while i disable this code. it remains fine. here is my code snippet for markup, js and php
HTML
<form class="shoform" id="contact-entry" name="contact-entry" action="project-up-eng.php" method="post" enctype="multipart/form-data">
<input class="pic" id="img" type="file" multiple="multiple" name="imgfile[]" />
<input class="submitbtn" id="submitbtn" type="submit" value="Add"></input>
</form>
JS
$("#submitbtn").click(function(){
$("#contact-entry").submit(function() {
/* Act on the event */
e.preventDefault();
$.post('project-up-eng.php',$(this).serialize(), function()
{
alert("OK");
});
});
});
PHP:
mkdir("projects/".$_POST['name']);
$path="projects/".$_POST['name'];
for($i=0;$i<count($_FILES['imgfile']['size']);$i++)
{
$file = $path."/".$_FILES['imgfile']['name'][$i];
move_uploaded_file($_FILES['imgfile']['tmp_name'][$i],$file);
}