Reputation: 13
I am trying to upload files 62 Mb. It giving me following error :
Failed to load resource
I am using following jquery for multiple upload :
var form_data = new FormData();
jQuery.each($('#images')[0].files, function(i, file) {
form_data.append('file[]', file);
});
form_data.append("postId", postId)
$.ajax({
url: '<?php echo get_bloginfo('template_directory') ?>/upload_files.php',
type: 'POST',
dataType: 'script/html',
contentType: 'multipart/form-data',
cache: false,
contentType: false,
processData: false,
data: form_data,
success: function(response) {
$("#show_progress").hide();
alert(response);
},
error: function() {
$("#show_progress").hide();
$("#end_progress").show();
$("#images").val('');
}
});
}
});
});
And php file :
foreach($_FILES['file']['tmp_name'] as $key =>$tmp_name )
{
$name = $_FILES['file']['name'][$key];
$tmp_name = $_FILES['file']['tmp_name'][$key];
$target_path = $gal_path."/". $_FILES["file"]["name"][$key];
move_uploaded_file($_FILES["file"]['tmp_name'][$key],$target_path);
mysql_query("INSERT INTO wp_group_upload SET upload_group_id = '$gid', upload_img_name = '$name'");
}
?>
Can you tell me what's wrong?
Upvotes: 0
Views: 69
Reputation: 1863
I think your problem is here :
See the single quotes!
url: '<?php echo get_bloginfo('template_directory') ?>/upload_files.php'
If template_directory
is a javascript variable, it must be written like this :
url: '<?php echo get_bloginfo('+template_directory+') ?>/upload_files.php'
If template_directory
is a string given to get_bloginfo()
function, it must be written like this :
url: '<?php echo get_bloginfo("template_directory") ?>/upload_files.php'
or :
url: "<?php echo get_bloginfo('template_directory') ?>/upload_files.php"
Upvotes: 2