简体   繁体   中英

Pdf Upload in Zend Framework 2

I'm just trying to upload a pdf file in my Project (coded with Zend Framework 2). I just can't figure out why nothing is uploaded.

The Controller:

$this->adapter = $this->getServiceLocator()->get('db-adapter');
    $jobModel = new Model\JobModel($this->adapter);
    $form    = EnterContentForm::getEnterContentFormJob($this->serviceManager);
    $templateData = $this->getServiceLocator()->get('TemplateData');
    $templateData->addTemplateData(array(
            'ckEditor' => true
    ));


    if($this->getRequest()->isPost()){
                    $pdfFile = $this->params()->fromFiles('pdf');

        $data    = array_merge_recursive(
                $this->getRequest()->getPost()->toArray(),
                $this->getRequest()->getFiles()->toArray()
        );
        $isPdf = new \Zend\Validator\File\MimeType('application/pdf');
        $form->setData($postData);


        if($form->isValid()){
            if($isPdf->isValid($pdfFile)){
                $adapter = new \Zend\File\Transfer\Adapter\Http(); 
                $adapter->setDestination("static_content\media\pdfs\jobs");
                $adapter->receive($pdfFile['name']);
            }}

I can't figure out why nothing is uploaded. I tried many ways but none of them worked, like:

Abdul Malik Ikhsan's Blog

Zend Doku

Thanks

对于我的项目,我使用Christopher Martin ZF2FileUploadExamples ,它对我有用

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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