简体   繁体   English

PHP-Imagick致命错误,没有解释

[英]PHP - Imagick fatal error, no explanation

So, I am trying to convert a pdf file into a jpeg file, but when i read the pdf file with readImage($_FILES["fileinput"]["tmp_name"]) the fatal error is given. 因此,我试图将pdf文件转换为jpeg文件,但是当我使用readImage($ _ FILES [“ fileinput”] [“ tmp_name”])读取pdf文件时,出现致命错误。 I get the file via html from which you can see below. 我通过html获取文件,您可以从下面看到。

HTML FORM: HTML格式:

<form enctype="multipart/form-data" class="generalForm" action="../includes/connect.php" method="POST">
            <label class="headLabel">DODAJ</label>
            <br>
            <br>
            <input class="inputTextSub" id="naziv" name="naziv" type="text">
            <br>
            <br>
            <input class="inputTextSub" id="opis" name="opis" type="text">
            <br>
            <br>
            <input class="inputTextSub" id="datumz" name="datumz" type="date">
            <br>
            <br>
            <input type="file" name="inputfile" id="file" class="inputfile" />
            <br>
            <br>
            <br>
            <input class="button" style="margin-top:2em;" name="save" type="submit" value=" shrani ">
        </form>

and then here is the code in php that i execute when user presses the button. 然后这是当用户按下按钮时我执行的php中的代码。

    if(isset($_POST['save'])){
    if(!$_POST['naziv']==""&&!$_POST['opis']==""&&!$_POST['datumz']==""
    &&!$_POST['datumk']==""&&isset($_POST['pr'])
    &&isset($_POST['format'])&&$_FILES['inputfile']['size']>0){
        $naziv = $_POST['naziv'];
        $opis = $_POST['opis'];
        $datumz = $_POST['datumz'];
        $datumk = $_POST['datumk'];
        $pr = $_POST['pr'];
        $format = $_POST['format'];
        $modId = $_SESSION['mod_id'];
        $file = file_get_contents($_FILES['inputfile']['tmp_name']);


                 $im = new Imagick();
/*THIS LINE*/    $im->readImage($_FILES['inputfile']['tmp_name'].'[0]');
                 $im->writeImage("lala.jpg");

and finnaly, the devil himself: 最后,魔鬼本人:

Fatal error: in C:\\xampp\\htdocs\\mod\\includes\\connect.php on line 49 致命错误:在第49行的C:\\ xampp \\ htdocs \\ mod \\ includes \\ connect.php中

Please help, im dying with this. 请帮忙,对此垂涎三尺。

It look like as you are using bad syntax. 看起来就像您使用的语法错误一样。

$_FILES['inputfile']['tmp_name'].'[0]'

I think you wanted to do something like this $_FILES['inputfile']['tmp_name'][0] 我认为您想做这样的事情$_FILES['inputfile']['tmp_name'][0]

If still it gives you error, try to debug it like this : 如果仍然给您错误,请尝试像这样调试它:

//$im = new Imagick();
//$im->readImage($_FILES['inputfile']['tmp_name'].'[0]');
//$im->writeImage("lala.jpg");
echo "<pre>";
print_r($_FILES['inputfile']['tmp_name']);

and check if element [0] exists or not. 并检查元素[0]存在。

If [0] element exists than replace this line $_FILES['inputfile']['tmp_name'][0] with $im->readImage($_FILES['inputfile']['tmp_name'].'[0]'); 如果存在[0]元素,则将该行$_FILES['inputfile']['tmp_name'][0]替换$im->readImage($_FILES['inputfile']['tmp_name'].'[0]');

If [0] element doesn't exists than use $im->readImage($_FILES['inputfile']['tmp_name']; 如果[0]元素不存在,则使用$im->readImage($_FILES['inputfile']['tmp_name'];

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM