Upload/Replace new images
ref: http://jsfiddle.net/vbrHA/
/*
- image exists in the database or will be uploaded in this form
- if the row->event_image exists echo the img src of that image
*/
<input type='button' id='remove' value='remove' class='hide'/>
<input type="file" id="filelogo" name="file" style="height:50px !important;">
<?php
if($event_image) {
echo '<img id="blah" src="http://'.SITEURL.'organizer/upload/'. $event_image.'"height="250" />';
}
<script>
// can't use this because there are already existing images in the database
//$('#blah').hide();
//$('#remove').hide();
function readURL(input) {
if (input.files && input.files[0]) {
var reader = new FileReader();
reader.onload = function (e) {
$('#blah').attr('src', e.target.result);
}
reader.readAsDataURL(input.files[0]);
}
}
$("#filelogo").change(function() {
if( $('#filelogo').val()!=""){
$('#remove').show();
$('#blah').show('slow');
}
else
{ $('#remove').hide();$('#blah').hide('slow');}
readURL(this);
});
$('#remove').click(function() {
$('#filelogo').val('');
$(this).hide();
$('#blah').hide('slow');
$('#blah').attr('src','http://upload.wikimedia.org/wikipedia/commons/thumb/4/40/No_pub.svg/150px-No_pub.svg.png');
});
</script>