I got a field in my HTML that send a file.. When the user selects an image they get a preview of the image they are about to upload (js). When this preview script is activated the $_FILES
post doesn't send any data (php verified with var_dump($_FILES)
).
Here is the JS:
function readURL(input) {
if (input.files && input.files[0]) {
var reader = new FileReader();
reader.onload = function (e) {
$('#preview')
.attr('src', e.target.result)
.css('display', 'block');
$('#upload').html('<i class="icon-upload"></i> <input type="file" onchange="readURL(this);" size="1" name="foto" class="input-file" />Cambiar imágen')
};
reader.readAsDataURL(input.files[0]); // <- If I delete this line it posts correctly but dosen't preview the image.
}
Someone sees the error?