139
rated 0 times
[
142]
[
3]
/ answers: 1 / hits: 15568
/ 11 Years ago, fri, september 13, 2013, 12:00:00
I am uploading files using jQuery.ajax
and everything works perfect in modern browsers like Google Chrome, Mozilla Firefox, Opera, except of Internet Explorer 10.
new FormData($('.uploadForm')[0])
doesnt work in IE10, but if I only try with this piece of code: new FormData($('.uploadForm'))
it works...Looks like it does not accept elements at specific index or something? I dont understand this realy good, that is the reason, why I am searching for help.
Does it exist any kind of workaround for this example for IE10?
JS:
var form = new FormData($('.uploadForm')[0]);
config.progressBar.progressWidth = 0;
$('.uploadForm .valueBox').fadeOut('slow',function(){
$(this).addClass('hidden')
$('.meter').removeClass('hidden').width(config.progressBar.width);
$.ajax({
url: '../../uploads/some.php',
type: 'POST',
xhr: function() {
var myXhr = $.ajaxSettings.xhr();
if(myXhr.upload){
myXhr.upload.onprogress = progress;
}
return myXhr;
},
success: function (res) {
console.log(res)
},
data: form,
cache: false,
contentType: false,
processData: false
});
Peace of some.php
code:
foreach($_FILES[file][error] as $key => $value) {
if ($value == UPLOAD_ERR_OK){
$name = $_FILES[file][name][$key];
$arr_files = getimagesize($_FILES[file][tmp_name][$key]);
$width = $arr_files[0];
$height = $arr_files[1];
$mime = $arr_files['mime'];
copy($_FILES['file']['tmp_name'][$key], '../uploads/upload/'.$name);
echo json_encode($_FILES);
}
}
IE10 error thrown: SCRIPT5: Access is denied.
More From » php