<a href="#" data-toggle="modal" data-target="#contact_dialog">
Change Picture
</a>
這裏不工作是我的形式
文件上傳自舉模式
<form id="picture_change" class="form-horizontal" action="include/picture_change.php" method="post" enctype="multipart/form-data">
<div class="form-group">
<input type="text" name="vals">
<h5 style="padding-top:5px; padding-bottom:5px;">Change Picture</h5>
<input type="file" name="proimg" class="file">
<div class="input-group col-xs-12">
<span class="input-group-addon"><i class="glyphicon glyphicon-picture"></i></span>
<input type="text" class="form-control input-sm" name="proimg" disabled placeholder="Upload Image">
<span class="input-group-btn">
<button class="browse btn btn-primary input-sm" type="button"><i class="glyphicon glyphicon-search"></i> Browse</button>
</span>
</div>
</div>
</form>
關閉
<script>
/* must apply only after HTML has loaded */
$(document).ready(function() {
$("#picture_change").on("submit", function(e) {
var postData = $(this).serializeArray();
var formURL = $(this).attr("action");
$.ajax({
url: formURL,
type: "POST",
data: postData,
success: function(data, textStatus, jqXHR) {
$('#contact_dialog .modal-header .modal-title').html("Result");
$('#contact_dialog .modal-body').html(data);
$("#submitForm").remove();
},
error: function(jqXHR, status, error) {
console.log(status + ": " + error);
}
});
e.preventDefault();
});
$("#submitForm").on('click', function() {
$("#picture_change").submit();
});
});
</script>
picture_change.php
$imgFile = $_FILES['proimg']['name'];
$tmp_dir = $_FILES['proimg']['tmp_name'];
$imgSize = $_FILES['proimg']['size'];
if(!empty($imgFile))
{
$upload_dir = '../images/profile_picture/'; // upload directory
$images = $ob->imageupload($imgFile,$tmp_dir,$imgSize,$upload_dir);
if($images['ermsg'] == '')
{
$ob->upddata("update tbl_safety_pros_signup set image='".$images['userpic']."' where id='".$_SESSION['user_id']."'");
}
else {
echo $msgs=$images['ermsg'];
}
}
我嘗試使用引導模式上傳圖片,但文件未上傳
其他輸入字段值在操作頁面上發佈,如何解決此問題。
請幫幫我。
http://stackoverflow.com/questions/166221/how-can-i-upload-files-asynchronously –