I'm going straight to the point here. I'm trying to upload a 400mb+ zip file using jquery and codeigniter. however, when the progress bar completes it gives me 500 Internal Server Error on the console log don't know what's causing this. I've tried it on my local files everything works fine. but when I put it online it gives me this 500 internal server error.
my hosting and my local have the same settings already.
upload_max_filesize 500M
post_max_size 500M
max_execution_time 3000
Here's my code:
HTML
<h1>Upload File</h1>
<hr />
<form method="post" name="upload_file" data-base-url="<?php echo site_url(array("main", "upload")); ?>" id="upload_file" action="<?php echo site_url(array("main", "do_upload")); ?>" enctype="multipart/form-data">
<p>File Type: <strong>(*)All</strong></p>
<!-- <p>File Type: <strong>doc, docx, pdf, xls, xlsx</strong> and <strong>txt</strong>.</p> -->
<input type="file" name="myfile" class="form-control" required><br>
<input type="submit" name="cmd_file_upload" id="cmd_file_upload" value="Upload File to Server" class="btn btn-default">
</form>
<br />
<p>File Uploaded: <a href="<?php echo base_url(); ?>uploaded_files/<?php echo $result['new_filename']; ?>" target="_blank"><?php echo $result['original_filename']; ?></a></p>
<div class="progress" style="display: none;">
<div class="progress-bar progress-bar-success progress-bar-striped" role="progressbar" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100" style="width:0%">
0% Complete (success)
</div>
</div>
JQUERY
$("#upload_file").on("submit", function(e){
e.preventDefault();
$("#cmd_file_upload").attr("disabled","disabled");
$(".progress").hide().show();
var $this = $(this);
var $url_transaction = $this.attr('action');
var $base_url = $this.data('base-url');
var formData = new FormData($this[0]);
$.ajax({
xhr: function() {
var xhr = new window.XMLHttpRequest();
xhr.upload.addEventListener("progress", function(evt) {
if (evt.lengthComputable) {
var percentComplete = evt.loaded / evt.total;
percentComplete = parseInt(percentComplete * 100);
console.log(percentComplete);
$(".progress-bar").attr('style','width:'+percentComplete+'%');
$(".progress-bar").html(percentComplete+'%');
if (percentComplete === 100) {
$(".progress-bar").html(percentComplete+'% Complete (Success)');
}
}
}, false);
return xhr;
},
beforeSend:function(){
$(".progress-bar").attr('style','width:0%');
$(".progress-bar").html();
},
url: $url_transaction,
type: "POST",
data: formData,
contentType: false,
processData: false,
// dataType: "json",
success: function(result) {
console.log(result);
setTimeout(function(){
if(result == 0){
window.location.href = $base_url;
}else{
window.location.href = $base_url+"/"+result;
}
}, 500);
}
});
});
PHP CODE
public function do_upload(){
$filename = "file_".md5(date('Y-m-d H:i:s'));
$config['file_name'] = $filename;
$config['upload_path'] = './uploaded_files';
$config['allowed_types'] = '*';
// $config['allowed_types'] = 'doc|docx|pdf|xls|xlsx|txt';
$config['max_size'] = 500000;
$this->load->library('upload', $config);
if ( ! $this->upload->do_upload('myfile'))
{
$error = array('error' => $this->upload->display_errors('<span>','</span>'));
$err = array("status_id" => "0", "message" => $error['error']);
$_SESSION['type'] = "warning";
$_SESSION['message'] = $error['error'];
echo 0;
}
else
{
$data = array('upload_data' => $this->upload->data());
$prev_filename=$data['upload_data']['client_name'];
$file_ext = $this->upload->data("file_ext");
$new_filename = $filename.$file_ext;
$result = $this->main_m->insert_data('uploaded_file', array('original_filename' => $prev_filename, 'new_filename' => $new_filename));
$_SESSION['type'] = "success";
$_SESSION['message'] = "File's Successfully Uploaded!";
echo $result;
}
}
thanks in advance.