. У меня есть страница, которая создает форму, содержащую загрузку файла в Bootstrap Modal.PHP/Javascript - Проверьте JS, если загрузка файла PHP прошла успешно
Представление формы составлено на Javascript, и мне нужно получить сообщение о загрузке файла, чтобы показать пользователю перед повторной загрузкой страницы. Вот пример:
HTML:
<div id="modal-insert-occurrence-form" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="modal-insert-occurrence-label" aria-hidden="true">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h3 id="modal-insert-occurrence-label">Insert occurrence</h3>
</div>
<div class="modal-body">
<form id="insert-occurrence-form">
<fieldset>
<label for="obs-occurrence">Obs</label>
<textarea name="obs-occurrence" id="obs-occurrence" rows=3 class="span4"></textarea>
<label for="image-occurrence">Screenshot</label>
<input type="file" name="image-occurrence" id="image-occurrence" />
</fieldset>
</form>
</div>
<div class="modal-footer">
<button id="modal-insert-occurrence-submit" class="btn btn-info" onClick="fileUp('insert-occurrence-form','ajax/upload.php');" >Insert</button>
<button class="btn" data-dismiss="modal" aria-hidden="true">Cancel</button>
</div>
</div>
JavaScript:
function fileUp(form_id, action_url) {
var form = document.getElementById(form_id);
form.setAttribute("action", action_url);
form.setAttribute("method", "post");
form.setAttribute("enctype", "multipart/form-data");
form.setAttribute("encoding", "multipart/form-data");
form.submit();
//Need to show the message here!
location.reload();
}
Что я могу сделать? Благодарю.
Вы можете использовать этот загрузчик или посмотреть его код, чтобы узнать, как они реализуют статус файла/статус http://blueimp.github.io/jQuery-File-Upload/ – Pitchinnate
@Pitchinnate Спасибо, друг. Это интересно, но мне нужен самый простой способ загрузки. – Minoru