500 Internal Server Error PHP脚本-尝试最多的答案 [英] 500 Internal Server Error PHP Script - Tried most answers

查看:85
本文介绍了500 Internal Server Error PHP脚本-尝试最多的答案的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

每当附有图片时,我的脚本似乎都将返回500错误,但是它正在返回目录中所需的文件吗?我尝试了phpinfo()并将定制的.user.ini放在我的目录中,但仍然以错误结束.我正在使用Godaddy& Plesk是否有帮助?

My script seems to be returning a 500 error whenever pictures are attached, however it is returning the files I wanted in my directory? I've tried phpinfo() and put a bespoke .user.ini in my directory and I'm still ending up with the error. I'm using Godaddy & Plesk if that helps?

<?php

set_time_limit(0);
ignore_user_abort(1);
ini_set('memory_limit','512M');

require('fpdf/fpdf.php');
$pdf = new FPDF();
$pdf->AddPage();
$pdf->SetFont('Helvetica','B',10);
$pdf->Image('some-url',10,10,50,50,'gif');
$pdf->SetXY(70,28);
$pdf->Cell(0,0,"Title",0,0,'C');
$pdf->SetXY(70,40);
$pdf->Cell(0,0,"Job Completion Certificate",0,0,'C');
$pdf->SetY(60);
$pdf->Write(14,$Data);
$pdf->SetY(225);
if(! empty($_POST["signature"])){
$pdf->Image($_POST["signature"],null,null,0,0,'png');
};
$pdf->AddPage('P','A4');

$allowedExts = array("gif", "jpeg", "jpg", "JPG", "JPEG", "PNG","png");
$pictures = array("file1", "file2", "file3");
$counter = 10;

foreach ($pictures as $value)
{
if ( ! empty($_FILES[$value]["tmp_name"])
&&($_FILES[$value]["size"] < 4000000)
&& in_array(end(explode(".", $_FILES[$value]["name"])), $allowedExts))
{
  move_uploaded_file($_FILES[$value]["tmp_name"],$_FILES[$value]["name"]);
  $pdf->Image($_FILES[$value]["name"],25,$counter,80,80);
  //unlink($_FILES["file"]["name"]);
  $counter += 90;
}
else
  {
  echo $value." is either Invalid or Not Attached<br>";
  };    
};
$pdf->Output($_POST["Customer"]."_".$_POST["Location"].'.pdf', 'F');

print "Data Written"; 

?>  

如果我将这段代码注释掉:

If I comment out this section of the code:

foreach ($pictures as $value)
{
if ( ! empty($_FILES[$value]["tmp_name"])
&&($_FILES[$value]["size"] < 4000000)
&& in_array(end(explode(".", $_FILES[$value]["name"])), $allowedExts))
{
  move_uploaded_file($_FILES[$value]["tmp_name"],$_FILES[$value]["name"]);
  $pdf->Image($_FILES[$value]["name"],25,$counter,80,80);
  //unlink($_FILES["file"]["name"]);
  $counter += 90;
}
else
  {
  echo $value." is either Invalid or Not Attached<br>";
  };    
};

它工作正常.

经过进一步检查并更改了我的web.config文件(请参阅

After further inspection and changing my web.config file (see http://support.godaddy.com/help/article/3430/disabling-windows-custom-error-messaging?locale=en&ci=46061) I get this error:

PHP Strict Standards:  Only variables should be passed by reference in G:\PleskVhosts\mysite\httpdocs\action.php on line 48

推荐答案

我最终不得不将代码更改为以下内容:

I ended up having to change my code to the below:

...
foreach ($pictures as $value)
{
$temp = explode(".", $_FILES[$value]["name"]);
$extension = end($temp);    
if ( ! empty($_FILES[$value]["tmp_name"])
&&($_FILES[$value]["size"] < 4000000)
&& in_array($extension, $allowedExts))
{...

如果其他任何人都在努力地在哥达& amp;上出现错误,请按照上面的链接,将web.config文件放在您的根文件夹和页面所在的文件夹中.一旦您知道问题出在哪里,解决起来就容易多了!

If anyone else struggles getting errors showing up on godaddy & plesk follow the link above and put the web.config file in your root folder and the folder that your page is in. Once you can see where the problem is it's a whole lot easier to solve!

这篇关于500 Internal Server Error PHP脚本-尝试最多的答案的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆