テキストエリアとアップロード画像ボタンがあります。アップロード画像ボタンには複数のオプションがあります。ユーザーが2〜3枚の写真をテキストエリアにテキストとともにアップロードし、ボタンを押すと、関数UserPost()に送信されます。ここでは、アップロードされたすべての画像を読むために入力タイプ[file]の内容を読み込むプロセスを知りたいと思います。以下は、コードです、親切に助けてください。JavaScriptを使用して入力タイプ[ファイル]から複数のファイルを読み込みます。
<div class="mainsection">
<div>
<div class="pull-left postimage">
<?php echo "<img src=profile_pic/".$ProfilePic ." />"; ?>
</div>
<div class="pull-left posttext">
<div class="postname"><?php echo $Name; ?>
</div>
<p><?php echo $UT." - ".$Designation." - ".$Company; ?></p>
</div>
<textarea id="posting" name="posting" rows="2"
cols="50" placeholder="Share something here...">
</textarea>
<div class="clear"></div>
<hr>
</div>
<!-- Show Image Preview -->
<table id="previewTable">
<thead id="columns"></thead>
<tbody id="previews"></tbody>
</table>
<div class="fileUpload btn btn-default">
<span>
<i class="fa fa-camera-retro" style="margin-right: 6px;" aria-hidden="true">
</i>Upload Image
</span>
<input type="file" class="upload" id="input_clone" multiple />
</div>
<div>
<input class="postall btn btn-primary pull-right" type="submit" onClick="UserPost()" value="Post">
</div>
<div class="clear"></div>
</div>
これはUserPost()関数である -
function UserPost() {
var x = document.getElementById('posting').value;
var timezone_offset_minutes = new Date().getTimezoneOffset();
timezone_offset_minutes = timezone_offset_minutes == 0 ? 0 : -timezone_offset_minutes;
$.ajax({
type: "POST",
url: "user-post.php?p="+x+"&tz="+timezone_offset_minutes,
success: function(data) {
$("#mainsectionID").load(" #mainsectionID");
document.getElementById('posting').value='';
}
});
}