I think the error is possibly the size of the upload. It’s 15MB.
I’m running Windows Plesk, not a great deal of support available.
When I upload a small PDF file, say 1MB it uploads correctly, but uploading larger PDF files just gives me a 500 Internal Server Error. There’s nothing in the log that indicates what the problem is either.
Here’s my code:
if(isset($_POST['addissue'])) {
if ($_FILES['pdf']['type'] != "application/pdf") {
// Type is not PDF display error
echo '<h2><strong>Error</strong> We can only accept PDF files at this time.</h2>';
} else {
// use timestamp to create unique title
$random_digit=time();
// declare where to upload the file
$targeta="../publication/" . $userid . "/$_GET[id]/".$random_digit."_".$_FILES['pdf']['name'];
// move the file
if(move_uploaded_file($_FILES['pdf']['tmp_name'],$targeta)){
// use timestamp to create unique title
$allowedExts = array("jpg", "jpeg", "gif", "png");
$extension = end(explode(".", $_FILES["file"]["name"]));
if ((($_FILES["file"]["type"] == "image/gif")
|| ($_FILES["file"]["type"] == "image/jpeg")
|| ($_FILES["file"]["type"] == "image/png")
|| ($_FILES["file"]["type"] == "image/pjpeg"))
&& ($_FILES["file"]["size"] < 60000)
&& in_array($extension, $allowedExts))
{
// Type is not PDF display error
echo '<h2><strong>Error</strong> We can only accept PDF files at this time.</h2>';
} else {
// declare where to upload the file
$target="../publication/" . $userid . "/$_GET[id]/".$random_digit."_".$_FILES['img']['name'];
// move the file
if(move_uploaded_file($_FILES['img']['tmp_name'],$target)){
// file has been uploaded, set message
$dialog = '<h2><strong>Success</strong> Your publication has been uploaded and is now awaiting moderation.</h2>';
// get string version of UK date
$date = date('m-d-Y');
// insert info to the db
$sth = $dbconn->prepare("
INSERT INTO publication_issue
(user_id, publication_id, issue_number, img, smallimg, pdf, upload_date, cat, viewcount, status, mod_status)
VALUES (:user_id,:publication_id,:issue_number,:img,:smallimg,:pdf,:upload_date,:cat,:viewcount,:status,:mod_status)
");
$params = array(
user_id => $userid,
publication_id => $_GET[id],
issue_number => $_POST[issue_number],
img => $target,
smallimg => 0,
pdf => $targeta,
upload_date => $date,
cat => $_POST[category],
viewcount => 0,
status => 1,
mod_status => 2
);
$sth->execute($params);
$result = $sth->fetch();
//echo $dbconn->lastInsertId();
echo $newid;
$ex = true;
}
else{
//There's an error
echo '<h2><strong>Error</strong> There was a problem uploading your publication.</h2>';
}
}
if ($ex = true){
//Everything inserted correctly, add image and update db
}}}
}
It’s not hitting any of the errors I have in place leading me to believe there’s nothing wrong with the code and I can’t think of any other reasons other than the size of the publication or the execution time.
I have tried to change this in the PHP INI file but to no avail.
PHP.INI:
max_execution_time 600
memory_limit 128M
upload_max_filesize 52428800
Are there any other things I can do to try and resolve this issue?
Thanks