【问题标题】:can't upload multiple images iin zend freamework on server无法在服务器上的zend框架中上传多个图像
【发布时间】:2023-03-07 19:20:01
【问题描述】:

我在服务器上使用 zend 框架上传 mutilply 文件时遇到问题

实际上我的代码在本地主机上可以正常工作,但在远程服务器上却给了我应用程序错误消息

我的主机是 ipage.com

$upload = new Zend_File_Transfer_Adapter_Http();
$upload->setDestination('projects\\'.$_pId);
// $_pid is my project folder where all files related to it uploded
$files = $upload->getFileInfo();
$i = 1;$g = 1;
foreach ($files as $file => $info)
{
    // i have three kinds of images
    // innerfinishingphotos_ images which can be more than 1 file eg :innerfinishingphotos_1, innerfinishingphotos_2, innerfinishingphotos_3.
    // outerfinishingphotos_ images which can be more than 1 file eg :outerfinishingphotos_1, outerfinishingphotos_2, outerfinishingphotos_3.
    // _main_photo image an image.

    // here i made if statements to determine which file came from which input file 

    if( $info == $files["innerfinishingphotos_".$i] && $info["name"] ==  $files["innerfinishingphotos_".$i]["name"] && !empty( $info["name"] ) )
    {
        $filename = "inner_finishing".$_pId.uniqid().$files["innerfinishingphotos_".$i]["name"];
        $upload->addFilter('Rename', $filename, $files["innerfinishingphotos_".$i]);
        $photodata =  Array ("project_id"=> $_pId, "photo_link"=> "/projects/".$_pId."/".$filename, "photo_name"=> "inner_finishing");
        $projectModel->addInProjectGalary($photodata);
        $i++;
    }
    else if( $info == $files["outerfinishingphotos_".$g] && $info["name"] == $files["outerfinishingphotos_".$g]["name"] &&!empty( $info["name"] ) )
    {
        $filename = "outer_finishing".$_pId.uniqid().$files["outerfinishingphotos_".$g]["name"];
            $upload->addFilter('Rename', $filename, $files["outerfinishingphotos_".$g]);
            $photodata =  Array ("project_id"=> $_pId, "photo_link"=> "/projects/".$_pId."/".$filename, "photo_name"=> "outer_finishing");
            $projectModel->addInProjectGalary($photodata);
            $g++;
    }
    else if ($info == $files["_main_photo"] && !empty( $info["name"] ))
    {
        $filename = "main_photo".$_pId.uniqid().$files["_main_photo"]["name"];
            $upload->addFilter('Rename', $filename, $files["_main_photo"]);
            $photodata =  Array ("project_id"=> $_pId, "photo_link"=> "/projects/".$_pId."/".$filename, "photo_name"=> "project_photo");
            $projectModel->addInProjectGalary($photodata);  
    }

    //then i receive the image
    if($upload->isValid($file))
    {
        try {
            $upload->receive($file);  
            }
            catch (Exception $e) {
                echo "upload exteption";
            }   
    }
}

我测试了这段代码,我在本地主机上正常工作,所有图片都上传了,它们的数据进入了我的数据库

但在我的远程主机 'ipage.com' 上不起作用。

请大家帮帮我

【问题讨论】:

  • 您收到什么错误信息? “应用程序错误”只是向用户显示的用户友好消息,请查看错误日志以获取实际错误消息。
  • 我怎样才能得到实际的错误?错误日志在哪里?
  • 我无法确定导致问题的原因。
  • 默认情况下它将在主 Apache 错误日志中(如果您使用的是 Apache)。试试 /var/log/apache2/error.log。否则请联系您的房东。
  • 在与我的主机客户服务联系后,他们告诉我应用程序中的问题不在服务器上,我在我的代码中找不到问题,有人可以帮助我吗?

标签: php zend-framework


【解决方案1】:

经过几个小时的尝试,我解决了问题,就在这一行

$upload->setDestination('projects\\'.$_pId);

改成

$upload->setDestination('projects/'.$_pId);

谢谢先生。蒂姆喷泉

【讨论】:

    猜你喜欢
    • 2020-08-22
    • 2011-11-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-02-13
    • 1970-01-01
    相关资源
    最近更新 更多