<form id="Form">
<input type="file" />
<input type="submit" value="Send" id="buttonSubmit">
</form>
$(document).ready(function () {
$("#buttonSubmit").bind("click", function (event) {
$('#Form').submit();
return false;
});
$('#Form').submit(function(e) {
var formData = new FormData(this);
$.ajax({
type:'POST',
url: '/url',
data:formData,
cache:false,
contentType: false,
processData: false,
success:function(data, status){
},
error: function (jqXHR, exception) {
}
});
e.preventDefault();
});
});
if(preg_match_all("/\[photo([^\[\]]*)\]/", $text, $preg, PREG_PATTERN_ORDER)){
foreach($preg[0] as $key => $value){
$i = $preg[1][$key];
//$photos - массив с картинками
if( $photos[$i-1]['file'] ){
$block = "<div><img src="'.$photos[$i-1]['file'],.'"></div>';
}else{
$block = ' ';
}
$text = str_replace($value, $block, $text);
}
}