i want to submit image(file) with other form element just using php and jquery not ajax -
my html here
<body> <form id="myform" method="post" action="formprocessing.php" enctype="multipart/form-data"> <input type="text" name="first_name" id="first_name" value=""><b/> <input type="text" name="last_name" id="last_name" value=""><br /> profile image: <input name="image" id="image" type="file" /><br /> <input type="submit" name="formsubmit" id="formsubmit" onclick="return false" value="submit"> </form> <div id="result"></div> </body>
****my jquery code bellow here****
$(document).ready(function(){ $('#formsubmit').click(function(){ var name = $('#first_name').val(); var lastname = $('#last_name').val(); var files = $('#image')[0].files[0]; if (name != '' && lastname != '' && filen != '' ) { $.post("formprocessing.php" , {ufname:name,ufiles:filen}, function(result){ //$("#spans").html("email exist."); $('#result').html(result); $('#myform')[0].reset(); }); } }); }); });
and php page want display out bellow
$name = $_post['ufname']; $lastname = $_post['ulname']; $img= $_files['ufiles']['name']; echo $name; echo $lastname; echo $img;
i want submit images , other form element using jquery , php ,my above code worked image file not upload, how can that?
if want upload image via php here how can
$extension = pathinfo($_files['ufiles']['name'], pathinfo_extension); $filename = '123_'.uniqid().'.'.$extension; move_uploaded_file($_files['profile_image']['tmp_name'], '../path/'.$filename);
Comments
Post a Comment