I am making an Ajax request to update a Mysql table. When I successfully upload a pdf file, the filename and filepath is updated in the table accordingly. The problem I am getting is this. When I upload a small file (414kb) the upload is successful and I am able to update my record. When the file is large (3.6Mb), the upload appears successful but the responseText I get from the Ajax request is a blank. I handled the php side with an IF/ELSE statement and therefore there should be no 'blank' response. I really do not understand where the problem is. Please see the code below.
My 'upload_max_filesize' is 32M.
JS:
function completeHandler(event){
document.getElementById('p_status').style.color = '#19A347';
if(xmlhttp_file.readyState == 4 && xmlhttp_file.status == 200){
if(xmlhttp_file.responseText == 'update_success'){
console.log('congratulations. Success');
}else{
console.log('fail!');
console.log('responsText: '+xmlhttp_file.responseText);
console.log('xmlhttp_file.readyState: '+ xmlhttp_file.readyState);
console.log('xmlhttp_file.status: '+ xmlhttp_file.status);
}
}
}
PHP:
$move_success = move_uploaded_file($file_TmpPath, "$pdf_dir/$file");
if($move_success){
// ESCAPE CHARACTERS BEFORE INSERTION INTO _DB
// INSERT 'filename', 'filename_uniq', 'filepath'
$file_name = $mysqli->real_escape_string($file_name);
$file_id = $mysqli->real_escape_string($file_id);
$file = $mysqli->real_escape_string($file);
$filepath = $mysqli->real_escape_string("$pdf_dir/$file");
$sql = "UPDATE pdf_library SET filename='$file_name', filename_uniq='$file_id', filepath='$filepath' WHERE id='$idOfPost'";
$result = $mysqli -> query($sql);
if($result){
echo 'update_success';
}else{
echo 'update_fail';
}
}else{
echo 'move fail';
}
When uploading a large pdf - Console:
fail!
new_home.js:1473 responsText:
new_home.js:1474 xmlhttp_file.readyState: 4
new_home.js:1475 xmlhttp_file.status: 200