tôi sẽ xem trước một hình ảnh hoặc hình ảnh trong một hình thức, nhưng nó không hoạt động và giao diện HTML code như thế này như sau:cách xem trước hình ảnh trước và sau khi tải lên?
<form action="" method="post" enctype="multipart/form-data" name="personal_image" id="newHotnessForm">
<p><label for="image">Upload Image:</label>
<input type="file" id="imageUpload"/></p>
<p><button type="submit" class="button">Save</button></p>
<div id="preview">
<img width="160px" height="120px" src="profile pic.jpg" id="thumb" />
</div>
</form>
và đưa JS mã/script dưới đây:
<script type="text/jaavascript">
$(document).ready(function(){
var thumb=$('#thumb');
new AjaxUpload('imageUpload',{
action:$('newHotnessForm').attr('action'),
name:'image',
onSubmit:function(file,extension){
$('#preview').addClass('loading');
},
onComplete:function(file,response){
thumb.load(function(){
$('#preview').removeClass('loading');
thumb.unbind();
});
thumb.attr('src',response);
}
});
});
Có 2 câu hỏi chính về biểu mẫu của tôi:
1.Tại sao bản xem trước của hình ảnh hoặc hình ảnh không hoạt động?
2.Làm thế nào để dán ảnh từ biểu mẫu khi nút lưu được nhấp, nó sẽ đi/liên kết đến một trang php hoặc php khác mà tôi đã tạo?
bản sao có thể có của [Xem trước hình ảnh trước khi được tải lên] (http://stackoverflow.com/questions/4459379/preview-an-image-before-it-is-uploaded) – Kakitori